From 8102538c5753ff3c9d55275df7c124655dd1d77f Mon Sep 17 00:00:00 2001
From: Jens Kroeger <kroeger@physi.uni-heidelberg.de>
Date: Wed, 18 Mar 2020 17:06:35 +0100
Subject: [PATCH] AnalysisTimingATLASpix: improved naming of histograms,
 improved axis labels + create histograms only if they are also filled (e.g.
 if timewalk correction is performed)

(cherry picked from commit feb17d9b46320221935e172867e864f04444bbe3)
---
 .../AnalysisTimingATLASpix.cpp                | 618 +++++++++---------
 .../AnalysisTimingATLASpix.h                  |  26 +-
 2 files changed, 337 insertions(+), 307 deletions(-)

diff --git a/src/modules/AnalysisTimingATLASpix/AnalysisTimingATLASpix.cpp b/src/modules/AnalysisTimingATLASpix/AnalysisTimingATLASpix.cpp
index eb2d7bf0f..47a64df25 100644
--- a/src/modules/AnalysisTimingATLASpix/AnalysisTimingATLASpix.cpp
+++ b/src/modules/AnalysisTimingATLASpix/AnalysisTimingATLASpix.cpp
@@ -46,9 +46,7 @@ AnalysisTimingATLASpix::AnalysisTimingATLASpix(Configuration config, std::shared
     }
     m_highTotCut = m_config.get<int>("high_tot_cut", 40);
     m_lowTotCut = m_config.get<int>("low_tot_cut", 40);
-    m_highChargeCut = m_config.get<double>("high_charge_cut", static_cast<double>(m_highTotCut));
-    m_leftTailCut = m_config.get<double>("left_tail_cut", static_cast<double>(Units::convert(-10, "ns")));
-    m_rightTailCut = m_config.get<double>("right_tail_cut", static_cast<double>(Units::convert(10, "ns")));
+    m_timingTailCut = m_config.get<double>("timing_tail_cut", static_cast<double>(Units::convert(20, "ns")));
 
     if(m_config.has("correction_file_row")) {
         m_correctionFile_row = m_config.get<std::string>("correction_file_row");
@@ -68,7 +66,9 @@ AnalysisTimingATLASpix::AnalysisTimingATLASpix(Configuration config, std::shared
     m_calcCorrections = m_config.get<bool>("calc_corrections", false);
     m_totBinExample = m_config.get<int>("tot_bin_example", 3);
 
-    m_inpixelBinSize = m_config.get<double>("inpixel_bin_size", Units::get<double>(1.0, "um"));
+    m_inpixelBinSize = m_config.get<XYVector>(
+        "inpixel_bin_size",
+        {static_cast<double>(Units::convert(1.0, "um")), static_cast<double>(Units::convert(1.0, "um"))});
 
     total_tracks_uncut = 0;
     tracks_afterChi2Cut = 0;
@@ -89,60 +89,61 @@ void AnalysisTimingATLASpix::initialise() {
     std::string name = "hTrackCorrelationTime";
     hTrackCorrelationTime =
         new TH1F(name.c_str(), name.c_str(), static_cast<int>(2. * m_timeCut), -1 * m_timeCut, m_timeCut);
-    hTrackCorrelationTime->GetXaxis()->SetTitle("Track time stamp - cluster time stamp [ns]");
+    hTrackCorrelationTime->GetXaxis()->SetTitle("ts_{track} - ts_{cluster} [ns]");
     hTrackCorrelationTime->GetYaxis()->SetTitle("# events");
 
     name = "hTrackCorrelationTimeAssoc";
     hTrackCorrelationTimeAssoc =
         new TH1F(name.c_str(), name.c_str(), static_cast<int>(2. * m_timeCut), -1 * m_timeCut, m_timeCut);
-    hTrackCorrelationTimeAssoc->GetXaxis()->SetTitle("track time stamp - cluster time stamp [ns]");
+    hTrackCorrelationTimeAssoc->GetXaxis()->SetTitle("ts_{track} - ts_{cluster} [ns]");
     hTrackCorrelationTimeAssoc->GetYaxis()->SetTitle("# events");
 
     name = "hTrackCorrelationTimeAssocVsTime";
     hTrackCorrelationTimeAssocVsTime = new TH2F(name.c_str(), name.c_str(), 3e3, 0, 3e3, 1e3, -5, 5);
-    hTrackCorrelationTimeAssocVsTime->GetYaxis()->SetTitle("track time stamp - cluster time stamp [us]");
+    hTrackCorrelationTimeAssocVsTime->GetYaxis()->SetTitle("ts_{track} - ts_{cluster} [us]");
     hTrackCorrelationTimeAssocVsTime->GetXaxis()->SetTitle("time [s]");
     hTrackCorrelationTimeAssocVsTime->GetZaxis()->SetTitle("# events");
 
-    name = "hTrackCorrelationTime_rowCorr";
-    std::string title = "hTrackCorrelationTime_rowCorr: row-by-row correction";
-    hTrackCorrelationTime_rowCorr =
-        new TH1F(name.c_str(), title.c_str(), static_cast<int>(2. * m_timeCut), -1 * m_timeCut, m_timeCut);
-    hTrackCorrelationTime_rowCorr->GetXaxis()->SetTitle("track time stamp - cluster time stamp [ns]");
-    hTrackCorrelationTime_rowCorr->GetYaxis()->SetTitle("# events");
-
-    name = "hTrackCorrelationTime_rowAndTimeWalkCorr";
-    hTrackCorrelationTime_rowAndTimeWalkCorr =
-        new TH1F(name.c_str(), name.c_str(), static_cast<int>(2. * m_timeCut), -1 * m_timeCut, m_timeCut);
-    hTrackCorrelationTime_rowAndTimeWalkCorr->GetXaxis()->SetTitle("track time stamp - cluster time stamp [ns]");
-    hTrackCorrelationTime_rowAndTimeWalkCorr->GetYaxis()->SetTitle("# events");
-
-    name = "hTrackCorrelationTime_rowAndTimeWalkCorr_l25";
-    hTrackCorrelationTime_rowAndTimeWalkCorr_l25 =
-        new TH1F(name.c_str(), name.c_str(), static_cast<int>(2. * m_timeCut), -1 * m_timeCut, m_timeCut);
-    hTrackCorrelationTime_rowAndTimeWalkCorr_l25->GetXaxis()->SetTitle(
-        "track time stamp - cluster time stamp [ns] (if seed tot < 25lsb)");
-    hTrackCorrelationTime_rowAndTimeWalkCorr_l25->GetYaxis()->SetTitle("# events");
-
-    name = "hTrackCorrelationTime_rowAndTimeWalkCorr_l40";
-    hTrackCorrelationTime_rowAndTimeWalkCorr_l40 =
-        new TH1F(name.c_str(), name.c_str(), static_cast<int>(2. * m_timeCut), -1 * m_timeCut, m_timeCut);
-    hTrackCorrelationTime_rowAndTimeWalkCorr_l40->GetXaxis()->SetTitle(
-        "track time stamp - cluster time stamp [ns] (if seed tot < 40lsb)");
-    hTrackCorrelationTime_rowAndTimeWalkCorr_l40->GetYaxis()->SetTitle("# events");
-
-    name = "hTrackCorrelationTime_rowAndTimeWalkCorr_g40";
-    hTrackCorrelationTime_rowAndTimeWalkCorr_g40 =
-        new TH1F(name.c_str(), name.c_str(), static_cast<int>(2. * m_timeCut), -1 * m_timeCut, m_timeCut);
-    hTrackCorrelationTime_rowAndTimeWalkCorr_g40->GetXaxis()->SetTitle(
-        "track time stamp - cluster time stamp [ns] (if seed tot > 40lsb)");
-    hTrackCorrelationTime_rowAndTimeWalkCorr_g40->GetYaxis()->SetTitle("# events");
+    if(m_pointwise_correction_row) {
+        name = "hTrackCorrelationTime_rowCorr";
+        std::string title = "hTrackCorrelationTime_rowCorr: row-by-row correction";
+        hTrackCorrelationTime_rowCorr =
+            new TH1F(name.c_str(), title.c_str(), static_cast<int>(2. * m_timeCut), -1 * m_timeCut, m_timeCut);
+        hTrackCorrelationTime_rowCorr->GetXaxis()->SetTitle("ts_{track} - ts_{cluster} [ns]");
+        hTrackCorrelationTime_rowCorr->GetYaxis()->SetTitle("# events");
+    }
 
-    name = "hTrackCorrelationTime_totBin_" + std::to_string(m_totBinExample);
-    hTrackCorrelationTime_example = new TH1D(name.c_str(), name.c_str(), 20000, -5000, 5000);
-    hTrackCorrelationTime_example->GetXaxis()->SetTitle(
-        "track time stamp - pixel time stamp [ns] (all pixels from cluster)");
-    hTrackCorrelationTime_example->GetYaxis()->SetTitle("# events");
+    if(m_pointwise_correction_timewalk) {
+        name = "hTrackCorrelationTime_rowAndTWCorr";
+        hTrackCorrelationTime_rowAndTWCorr =
+            new TH1F(name.c_str(), name.c_str(), static_cast<int>(2. * m_timeCut), -1 * m_timeCut, m_timeCut);
+        hTrackCorrelationTime_rowAndTWCorr->GetXaxis()->SetTitle("ts_{track} - ts_{cluster} [ns]");
+        hTrackCorrelationTime_rowAndTWCorr->GetYaxis()->SetTitle("# events");
+
+        name = "hTrackCorrelationTime_rowAndTWCorr_l25";
+        hTrackCorrelationTime_rowAndTWCorr_l25 =
+            new TH1F(name.c_str(), name.c_str(), static_cast<int>(2. * m_timeCut), -1 * m_timeCut, m_timeCut);
+        hTrackCorrelationTime_rowAndTWCorr_l25->GetXaxis()->SetTitle("ts_{track} - ts_{cluster} [ns] (if seed tot < 25lsb)");
+        hTrackCorrelationTime_rowAndTWCorr_l25->GetYaxis()->SetTitle("# events");
+
+        name = "hTrackCorrelationTime_rowAndTWCorr_l40";
+        hTrackCorrelationTime_rowAndTWCorr_l40 =
+            new TH1F(name.c_str(), name.c_str(), static_cast<int>(2. * m_timeCut), -1 * m_timeCut, m_timeCut);
+        hTrackCorrelationTime_rowAndTWCorr_l40->GetXaxis()->SetTitle("ts_{track} - ts_{cluster} [ns] (if seed tot < 40lsb)");
+        hTrackCorrelationTime_rowAndTWCorr_l40->GetYaxis()->SetTitle("# events");
+
+        name = "hTrackCorrelationTime_rowAndTWCorr_g40";
+        hTrackCorrelationTime_rowAndTWCorr_g40 =
+            new TH1F(name.c_str(), name.c_str(), static_cast<int>(2. * m_timeCut), -1 * m_timeCut, m_timeCut);
+        hTrackCorrelationTime_rowAndTWCorr_g40->GetXaxis()->SetTitle("ts_{track} - ts_{cluster} [ns] (if seed tot > 40lsb)");
+        hTrackCorrelationTime_rowAndTWCorr_g40->GetYaxis()->SetTitle("# events");
+
+        name = "hTrackCorrelationTime_totBin_" + std::to_string(m_totBinExample);
+        hTrackCorrelationTime_example = new TH1D(name.c_str(), name.c_str(), 20000, -5000, 5000);
+        hTrackCorrelationTime_example->GetXaxis()->SetTitle(
+            "track time stamp - pixel time stamp [ns] (all pixels from cluster)");
+        hTrackCorrelationTime_example->GetYaxis()->SetTitle("# events");
+    }
 
     // 2D histograms:
     // column dependence
@@ -150,47 +151,53 @@ void AnalysisTimingATLASpix::initialise() {
     hTrackCorrelationTimeVsCol = new TH2F(
         name.c_str(), name.c_str(), 20000, -5000, 5000, m_detector->nPixels().X(), -0.5, m_detector->nPixels().X() - 0.5);
     hTrackCorrelationTimeVsCol->GetYaxis()->SetTitle("pixel column");
-    hTrackCorrelationTimeVsCol->GetXaxis()->SetTitle("track time stamp - seed pixel time stamp [ns]");
+    hTrackCorrelationTimeVsCol->GetXaxis()->SetTitle("ts_{track} - ts_{seed pixel} [ns]");
     // row dependence
     name = "hTrackCorrelationTimeVsRow";
     hTrackCorrelationTimeVsRow = new TH2F(
         name.c_str(), name.c_str(), 20000, -5000, 5000, m_detector->nPixels().Y(), -0.5, m_detector->nPixels().Y() - 0.5);
     hTrackCorrelationTimeVsRow->GetYaxis()->SetTitle("pixel row");
-    hTrackCorrelationTimeVsRow->GetXaxis()->SetTitle("track time stamp - seed pixel time stamp [ns]");
+    hTrackCorrelationTimeVsRow->GetXaxis()->SetTitle("ts_{track} - ts_{seed pixel} [ns]");
     name = "hTrackCorrelationTimeVsRow_1px";
     hTrackCorrelationTimeVsRow_1px = new TH2F(
         name.c_str(), name.c_str(), 20000, -5000, 5000, m_detector->nPixels().Y(), -0.5, m_detector->nPixels().Y() - 0.5);
     hTrackCorrelationTimeVsRow_1px->GetYaxis()->SetTitle("pixel row");
-    hTrackCorrelationTimeVsRow_1px->GetXaxis()->SetTitle(
-        "track time stamp - seed pixel time stamp [ns] (single-pixel clusters)");
+    hTrackCorrelationTimeVsRow_1px->GetXaxis()->SetTitle("ts_{track} - ts_{seed pixel} [ns] (single-pixel clusters)");
     name = "hTrackCorrelationTimeVsRow_npx";
     hTrackCorrelationTimeVsRow_npx = new TH2F(
         name.c_str(), name.c_str(), 20000, -5000, 5000, m_detector->nPixels().Y(), -0.5, m_detector->nPixels().Y() - 0.5);
     hTrackCorrelationTimeVsRow_npx->GetYaxis()->SetTitle("pixel row");
-    hTrackCorrelationTimeVsRow_npx->GetXaxis()->SetTitle(
-        "track time stamp - seed pixel time stamp [ns] (multi-pixel clusters)");
+    hTrackCorrelationTimeVsRow_npx->GetXaxis()->SetTitle("ts_{track} - ts_{seed pixel} [ns] (multi-pixel clusters)");
 
     // control plot: row dependence after row correction
-    name = "hTrackCorrelationTimeVsRow_rowCorr";
-    hTrackCorrelationTimeVsRow_rowCorr = new TH2F(
-        name.c_str(), name.c_str(), 20000, -5000, 5000, m_detector->nPixels().Y(), -0.5, m_detector->nPixels().Y() - 0.5);
-    hTrackCorrelationTimeVsRow_rowCorr->GetYaxis()->SetTitle("pixel row");
-    hTrackCorrelationTimeVsRow_rowCorr->GetXaxis()->SetTitle("track time stamp - seed pixel time stamp [ns]");
+    if(m_pointwise_correction_row) {
+        name = "hTrackCorrelationTimeVsRow_rowCorr";
+        hTrackCorrelationTimeVsRow_rowCorr = new TH2F(name.c_str(),
+                                                      name.c_str(),
+                                                      20000,
+                                                      -5000,
+                                                      5000,
+                                                      m_detector->nPixels().Y(),
+                                                      -0.5,
+                                                      m_detector->nPixels().Y() - 0.5);
+        hTrackCorrelationTimeVsRow_rowCorr->GetYaxis()->SetTitle("pixel row");
+        hTrackCorrelationTimeVsRow_rowCorr->GetXaxis()->SetTitle("ts_{track} - ts_{seed pixel} [ns]");
+    }
 
     // control plot: time walk dependence, not row corrected
     name = "hTrackCorrelationTimeVsTot";
     hTrackCorrelationTimeVsTot = new TH2F(name.c_str(), name.c_str(), 20000, -5000, 5000, 512, 0, 512);
-    hTrackCorrelationTimeVsTot->GetYaxis()->SetTitle("seed pixel ToT [ns]");
+    hTrackCorrelationTimeVsTot->GetYaxis()->SetTitle("seed pixel tot [lsb]}");
     hTrackCorrelationTimeVsTot->GetXaxis()->SetTitle("ts_{track} - ts_{cluster} [ns]");
 
     name = "hTrackCorrelationTimeVsTot_1px";
     hTrackCorrelationTimeVsTot_1px = new TH2F(name.c_str(), name.c_str(), 20000, -5000, 5000, 512, 0, 512);
-    hTrackCorrelationTimeVsTot_1px->GetYaxis()->SetTitle("seed pixel ToT [ns] (if clustersize = 1)");
+    hTrackCorrelationTimeVsTot_1px->GetYaxis()->SetTitle("seed pixel tot [lsb]} (if clustersize = 1)");
     hTrackCorrelationTimeVsTot_1px->GetXaxis()->SetTitle("ts_{track} - ts_{cluster} [ns]");
 
     name = "hTrackCorrelationTimeVsTot_npx";
     hTrackCorrelationTimeVsTot_npx = new TH2F(name.c_str(), name.c_str(), 20000, -5000, 5000, 512, 0, 512);
-    hTrackCorrelationTimeVsTot_npx->GetYaxis()->SetTitle("seed pixel ToT [ns] (if clustersize > 1)");
+    hTrackCorrelationTimeVsTot_npx->GetYaxis()->SetTitle("seed pixel tot [lsb]} (if clustersize > 1)");
     hTrackCorrelationTimeVsTot_npx->GetXaxis()->SetTitle("ts_{track} - ts_{cluster} [ns]");
 
     name = "hClusterTimeMinusPixelTime";
@@ -199,41 +206,52 @@ void AnalysisTimingATLASpix::initialise() {
         "ts_{cluster} - ts_{pixel} [ns] (all pixels from cluster (if clusterSize>1))");
 
     // timewalk after row correction
-    name = "hTrackCorrelationTimeVsTot_rowCorr";
-    hTrackCorrelationTimeVsTot_rowCorr = new TH2F(name.c_str(), name.c_str(), 20000, -5000, 5000, 512, 0, 512);
-    hTrackCorrelationTimeVsTot_rowCorr->GetYaxis()->SetTitle("seed pixel ToT [ns]");
-    hTrackCorrelationTimeVsTot_rowCorr->GetXaxis()->SetTitle("track time stamp - seed pixel time stamp [ns]");
-
-    name = "hTrackCorrelationTimeVsTot_rowCorr_1px";
-    hTrackCorrelationTimeVsTot_rowCorr_1px = new TH2F(name.c_str(), name.c_str(), 20000, -5000, 5000, 512, 0, 512);
-    hTrackCorrelationTimeVsTot_rowCorr_1px->GetYaxis()->SetTitle("seed pixel ToT [ns] (single-pixel clusters)");
-    hTrackCorrelationTimeVsTot_rowCorr_1px->GetXaxis()->SetTitle("ts_{track} - ts_{cluster} [ns]");
-
-    name = "hTrackCorrelationTimeVsTot_rowCorr_npx";
-    hTrackCorrelationTimeVsTot_rowCorr_npx = new TH2F(name.c_str(), name.c_str(), 20000, -5000, 5000, 512, 0, 512);
-    hTrackCorrelationTimeVsTot_rowCorr_npx->GetYaxis()->SetTitle("seed pixel ToT [ns] (multi-pixel clusters)");
-    hTrackCorrelationTimeVsTot_rowCorr_npx->GetXaxis()->SetTitle("ts_{track} - ts_{cluster} [ns]");
+    if(m_pointwise_correction_row) {
+        name = "hTrackCorrelationTimeVsTot_rowCorr";
+        hTrackCorrelationTimeVsTot_rowCorr = new TH2F(name.c_str(), name.c_str(), 20000, -5000, 5000, 512, 0, 512);
+        hTrackCorrelationTimeVsTot_rowCorr->GetYaxis()->SetTitle("seed pixel tot [lsb]}");
+        hTrackCorrelationTimeVsTot_rowCorr->GetXaxis()->SetTitle("ts_{track} - ts_{seed pixel} [ns]");
+
+        name = "hTrackCorrelationTimeVsTot_rowCorr_1px";
+        hTrackCorrelationTimeVsTot_rowCorr_1px = new TH2F(name.c_str(), name.c_str(), 20000, -5000, 5000, 512, 0, 512);
+        hTrackCorrelationTimeVsTot_rowCorr_1px->GetYaxis()->SetTitle("seed pixel tot [lsb]} (single-pixel clusters)");
+        hTrackCorrelationTimeVsTot_rowCorr_1px->GetXaxis()->SetTitle("ts_{track} - ts_{cluster} [ns]");
+
+        name = "hTrackCorrelationTimeVsTot_rowCorr_npx";
+        hTrackCorrelationTimeVsTot_rowCorr_npx = new TH2F(name.c_str(), name.c_str(), 20000, -5000, 5000, 512, 0, 512);
+        hTrackCorrelationTimeVsTot_rowCorr_npx->GetYaxis()->SetTitle("seed pixel tot [lsb]} (multi-pixel clusters)");
+        hTrackCorrelationTimeVsTot_rowCorr_npx->GetXaxis()->SetTitle("ts_{track} - ts_{cluster} [ns]");
+    }
 
     // final plots with both row and timewalk correction:
-    name = "hTrackCorrelationTimeVsRow_rowAndTimeWalkCorr";
-    hTrackCorrelationTimeVsRow_rowAndTimeWalkCorr = new TH2F(
-        name.c_str(), name.c_str(), 20000, -5000, 5000, m_detector->nPixels().Y(), -0.5, m_detector->nPixels().Y() - 0.5);
-    hTrackCorrelationTimeVsRow_rowAndTimeWalkCorr->GetYaxis()->SetTitle("row");
-    hTrackCorrelationTimeVsRow_rowAndTimeWalkCorr->GetXaxis()->SetTitle("track time stamp - seed pixel time stamp [ns]");
-
-    name = "hTrackCorrelationTimeVsTot_rowAndTimeWalkCorr";
-    hTrackCorrelationTimeVsTot_rowAndTimeWalkCorr = new TH2F(name.c_str(), name.c_str(), 20000, -5000, 5000, 512, 0, 512);
-    hTrackCorrelationTimeVsTot_rowAndTimeWalkCorr->GetYaxis()->SetTitle("seed pixel ToT [ns]");
-    hTrackCorrelationTimeVsTot_rowAndTimeWalkCorr->GetXaxis()->SetTitle("ts_{track} - ts_{cluster} [ns]");
+    if(m_pointwise_correction_timewalk) {
+        name = "hTrackCorrelationTimeVsRow_rowAndTWCorr";
+        hTrackCorrelationTimeVsRow_rowAndTWCorr = new TH2F(name.c_str(),
+                                                           name.c_str(),
+                                                           20000,
+                                                           -5000,
+                                                           5000,
+                                                           m_detector->nPixels().Y(),
+                                                           -0.5,
+                                                           m_detector->nPixels().Y() - 0.5);
+        hTrackCorrelationTimeVsRow_rowAndTWCorr->GetYaxis()->SetTitle("row");
+        hTrackCorrelationTimeVsRow_rowAndTWCorr->GetXaxis()->SetTitle("ts_{track} - ts_{seed pixel} [ns]");
+
+        name = "hTrackCorrelationTimeVsTot_rowAndTWCorr";
+        hTrackCorrelationTimeVsTot_rowAndTWCorr = new TH2F(name.c_str(), name.c_str(), 20000, -5000, 5000, 512, 0, 512);
+        hTrackCorrelationTimeVsTot_rowAndTWCorr->GetYaxis()->SetTitle("seed pixel tot [lsb]}");
+        hTrackCorrelationTimeVsTot_rowAndTWCorr->GetXaxis()->SetTitle("ts_{track} - ts_{cluster} [ns]");
+    }
 
     // in-pixel time resolution plots:
-    auto nbins_x = static_cast<int>(std::ceil(m_detector->pitch().X() / m_inpixelBinSize));
-    auto nbins_y = static_cast<int>(std::ceil(m_detector->pitch().Y() / m_inpixelBinSize));
+    auto nbins_x = static_cast<int>(std::ceil(m_detector->pitch().X() / m_inpixelBinSize.X()));
+    auto nbins_y = static_cast<int>(std::ceil(m_detector->pitch().Y() / m_inpixelBinSize.Y()));
     if(nbins_x > 1e4 || nbins_y > 1e4) {
         throw InvalidValueError(m_config, "inpixel_bin_size", "Too many bins for in-pixel histograms.");
     }
 
-    title = "in-pixel time resolution map;x [px];y [px];ts_{track} - ts_{cluster} [ns]";
+    std::string title =
+        "in-pixel time resolution map;in-pixel x_{track} [#mum];in-pixel y_{track} [#mum];ts_{track} - ts_{cluster} [ns]";
     hPixelTrackCorrelationTimeMap = new TProfile2D("pixelTrackCorrelationTimeMap",
                                                    title.c_str(),
                                                    nbins_x,
@@ -251,21 +269,21 @@ void AnalysisTimingATLASpix::initialise() {
     hClusterSizeVsTot_Assoc->GetXaxis()->SetTitle("clusterSize");
 
     hHitMapAssoc = new TH2F("hitMapAssoc",
-                            "hitMapAssoc; x_{track} [px]; x_{track} [px]; # entries",
+                            "hitMapAssoc; x_{track} [px]; y_{track} [px];# entries",
                             m_detector->nPixels().X(),
                             -0.5,
                             m_detector->nPixels().X() - 0.5,
                             m_detector->nPixels().Y(),
-                            -0.5,
-                            m_detector->nPixels().Y() - 0.5);
-    hHitMapAssoc_highCharge = new TH2F("hitMapAssoc_highCharge",
-                                       "hitMapAssoc_highCharge; x_{track} [px]; x_{track} [px]; # entries",
-                                       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,
+                            m_detector->nPixels().Y());
+    hHitMapAssoc_highToT = new TH2F("hitMapAssoc_highToT",
+                                    "hitMapAssoc_highToT; x_{track} [px]; y_{track} [px];# entries",
+                                    m_detector->nPixels().X(),
+                                    -0.5,
+                                    m_detector->nPixels().X() - 0.5,
+                                    m_detector->nPixels().Y(),
+                                    -0.5,
+                                    m_detector->nPixels().Y() - 0.5);
     hHitMapAssoc_inPixel = new TH2F("hitMapAssoc_inPixel",
                                     "hitMapAssoc_inPixel; in-pixel x_{track} [#mum]; in-pixel y_{track} [#mum]",
                                     static_cast<int>(pitch_x),
@@ -274,17 +292,19 @@ void AnalysisTimingATLASpix::initialise() {
                                     static_cast<int>(pitch_y),
                                     -pitch_y / 2.,
                                     pitch_y / 2.);
-    hHitMapAssoc_inPixel_highCharge =
-        new TH2F("hitMapAssoc_inPixel_highCharge",
-                 "hitMapAssoc_inPixel_highCharge;in-pixel x_{track} [#mum];in-pixel y_{track} [#mum]",
-                 static_cast<int>(pitch_x),
-                 -pitch_x / 2.,
-                 pitch_x / 2.,
-                 static_cast<int>(pitch_y),
-                 -pitch_y / 2.,
-                 pitch_y / 2.);
+    if(m_config.has("high_tot_cut")) {
+        hHitMapAssoc_inPixel_highToT =
+            new TH2F("hitMapAssoc_inPixel_highToT",
+                     "hitMapAssoc_inPixel_highToT;in-pixel x_{track} [#mum];in-pixel y_{track} [#mum]",
+                     static_cast<int>(pitch_x),
+                     -pitch_x / 2.,
+                     pitch_x / 2.,
+                     static_cast<int>(pitch_y),
+                     -pitch_y / 2.,
+                     pitch_y / 2.);
+    }
     hClusterMapAssoc = new TH2F("hClusterMapAssoc",
-                                "hClusterMapAssoc; x_{cluster} [px]; x_{cluster} [px]; # entries",
+                                "hClusterMapAssoc; x_{cluster} [px]; y_{cluster} [px];# entries",
                                 m_detector->nPixels().X(),
                                 -0.5,
                                 m_detector->nPixels().X() - 0.5,
@@ -304,141 +324,149 @@ void AnalysisTimingATLASpix::initialise() {
     hTotVsTime = new TH2F("hTotVsTime", "hTotVsTime", 64, 0, 64, 1e6, 0, 100);
     hTotVsTime->GetXaxis()->SetTitle("pixel ToT [lsb]");
     hTotVsTime->GetYaxis()->SetTitle("time [s]");
-    hTotVsTime_high = new TH2F("hTotVsTime_high", "hTotVsTime_high", 64, 0, 64, 1e6, 0, 100);
-    hTotVsTime_high->GetXaxis()->SetTitle("pixel ToT [lsb] if > high_tot_cut");
-    hTotVsTime_high->GetYaxis()->SetTitle("time [s]");
-
-    // control plots for "left tail" and "main peak" of time correlation
-    hInPixelMap_leftTail = new TH2F("hPixelMap_leftTail",
-                                    "in-pixel track position (left tail of time residual);in-pixel x_{track} "
-                                    "[#mum];in-pixel y_{track} [#mum];# entries",
-                                    nbins_x,
-                                    -pitch_x / 2.,
-                                    pitch_x / 2.,
-                                    nbins_y,
-                                    -pitch_y / 2.,
-                                    pitch_y / 2.);
-    hInPixelMap_rightTail = new TH2F("hPixelMap_rightTail",
-                                     "in-pixel track position (right tail of time residual);in-pixel x_{track} "
-                                     "[#mum];in-pixel y_{track} [#mum];# entries",
-                                     nbins_x,
-                                     -pitch_x / 2.,
-                                     pitch_x / 2.,
-                                     nbins_y,
-                                     -pitch_y / 2.,
-                                     pitch_y / 2.);
-    hInPixelMap_mainPeak = new TH2F("hPixelMap_mainPeak",
-                                    "in-pixel track position (main peak of time residual);in-pixel x_{track} "
-                                    "[#mum];in-pixel y_{track} [#mum];# entries",
-                                    nbins_x,
-                                    -pitch_x / 2.,
-                                    pitch_x / 2.,
-                                    nbins_y,
-                                    -pitch_y / 2.,
-                                    pitch_y / 2.);
-    hClusterMap_leftTail =
-        new TH2F("hClusterMap_leftTail",
-                 "hClusterMap (left tail of time residual); x_{cluster} [px]; x_{cluster} [px]; # entries",
-                 m_detector->nPixels().X(),
-                 -0.5,
-                 m_detector->nPixels().X() - 0.5,
-                 m_detector->nPixels().Y(),
-                 -0.5,
-                 m_detector->nPixels().Y() - 0.5);
-    hClusterMap_rightTail =
-        new TH2F("hClusterMap_rightTail",
-                 "hClusterMap (right tail of time residual); x_{cluster} [px]; x_{cluster} [px]; # entries",
-                 m_detector->nPixels().X(),
-                 -0.5,
-                 m_detector->nPixels().X() - 0.5,
-                 m_detector->nPixels().Y(),
-                 -0.5,
-                 m_detector->nPixels().Y() - 0.5);
-    hClusterMap_mainPeak =
-        new TH2F("hClusterMap_mainPeak",
-                 "hClusterMap (main peak of time residual); x_{cluster} [px]; x_{cluster} [px]; # entries",
-                 m_detector->nPixels().X(),
-                 -0.5,
-                 m_detector->nPixels().X() - 0.5,
-                 m_detector->nPixels().Y(),
-                 -0.5,
-                 m_detector->nPixels().Y() - 0.5);
-    hClusterSize_leftTail =
-        new TH1F("clusterSize_leftTail", "clusterSize (left tail of time residual); cluster size; # entries", 100, 0, 100);
-    hClusterSize_rightTail =
-        new TH1F("clusterSize_rightTail", "clusterSize (right tail of time residual); cluster size; # entries", 100, 0, 100);
-    hClusterSize_mainPeak =
-        new TH1F("clusterSize_mainPeak", "clusterSize (main peak of time residual); cluster size; # entries", 100, 0, 100);
-    hTot_leftTail =
-        new TH1F("hTot_leftTail", "ToT (left tail of time residual);seed pixel ToT [lsb]; # events", 2 * 64, -64, 64);
-    hTot_rightTail =
-        new TH1F("hTot_rightTail", "ToT (right tail of time residual);seed pixel ToT [lsb]; # events", 2 * 64, -64, 64);
-    hTot_mainPeak = new TH1F(
-        "hTot_mainPeak", "ToT (main peak of time residual, 1px clusters);seed pixel ToT [lsb]; # events", 2 * 64, -64, 64);
-    hTot_leftTail_1px = new TH1F("hTot_leftTail_1px",
-                                 "ToT (left tail of time residual, 1px clusters);seed pixel ToT [lsb]; # events",
-                                 2 * 64,
-                                 -64,
-                                 64);
-    hTot_rightTail_1px = new TH1F("hTot_rightTail_1px",
-                                  "ToT (right tail of time residual, 1px clusters);seed pixel ToT [lsb]; # events",
-                                  2 * 64,
-                                  -64,
-                                  64);
-    hTot_mainPeak_1px = new TH1F("hTot_mainPeak_1px",
-                                 "ToT (main peak of time residual, 1px clusters);seed pixel ToT [lsb]; # events",
+    if(m_config.has("high_tot_cut")) {
+        hTotVsTime_high = new TH2F("hTotVsTime_high", "hTotVsTime_high", 64, 0, 64, 1e6, 0, 100);
+        hTotVsTime_high->GetXaxis()->SetTitle("pixel ToT [lsb] if > high_tot_cut");
+        hTotVsTime_high->GetYaxis()->SetTitle("time [s]");
+    }
+
+    // control plots for "left/right tail" and "main peak" of the track time correlation
+    if(m_config.has("timing_tail_cut") && m_pointwise_correction_timewalk) {
+        hInPixelMap_leftTail = new TH2F("hPixelMap_leftTail",
+                                        "in-pixel track position (left tail of time residual);in-pixel x_{track} "
+                                        "[#mum];in-pixel y_{track} [#mum];# entries",
+                                        nbins_x,
+                                        -pitch_x / 2.,
+                                        pitch_x / 2.,
+                                        nbins_y,
+                                        -pitch_y / 2.,
+                                        pitch_y / 2.);
+        hInPixelMap_rightTail = new TH2F("hPixelMap_rightTail",
+                                         "in-pixel track position (right tail of time residual);in-pixel x_{track} "
+                                         "[#mum];in-pixel y_{track} [#mum];# entries",
+                                         nbins_x,
+                                         -pitch_x / 2.,
+                                         pitch_x / 2.,
+                                         nbins_y,
+                                         -pitch_y / 2.,
+                                         pitch_y / 2.);
+        hInPixelMap_mainPeak = new TH2F("hPixelMap_mainPeak",
+                                        "in-pixel track position (main peak of time residual);in-pixel x_{track} "
+                                        "[#mum];in-pixel y_{track} [#mum];# entries",
+                                        nbins_x,
+                                        -pitch_x / 2.,
+                                        pitch_x / 2.,
+                                        nbins_y,
+                                        -pitch_y / 2.,
+                                        pitch_y / 2.);
+        hClusterMap_leftTail =
+            new TH2F("hClusterMap_leftTail",
+                     "hClusterMap (left tail of time residual); x_{cluster} [px]; x_{cluster} [px];# entries",
+                     m_detector->nPixels().X(),
+                     -0.5,
+                     m_detector->nPixels().X() - 0.5,
+                     m_detector->nPixels().Y(),
+                     -0.5,
+                     m_detector->nPixels().Y() - 0.5);
+        hClusterMap_rightTail =
+            new TH2F("hClusterMap_rightTail",
+                     "hClusterMap (right tail of time residual); x_{cluster} [px]; x_{cluster} [px];# entries",
+                     m_detector->nPixels().X(),
+                     -0.5,
+                     m_detector->nPixels().X() - 0.5,
+                     m_detector->nPixels().Y(),
+                     -0.5,
+                     m_detector->nPixels().Y() - 0.5);
+        hClusterMap_mainPeak =
+            new TH2F("hClusterMap_mainPeak",
+                     "hClusterMap (main peak of time residual); x_{cluster} [px]; x_{cluster} [px];# entries",
+                     m_detector->nPixels().X(),
+                     -0.5,
+                     m_detector->nPixels().X() - 0.5,
+                     m_detector->nPixels().Y(),
+                     -0.5,
+                     m_detector->nPixels().Y() - 0.5);
+        hClusterSize_leftTail =
+            new TH1F("clusterSize_leftTail", "clusterSize (left tail of time residual);cluster size;# entries", 100, 0, 100);
+        hClusterSize_rightTail = new TH1F(
+            "clusterSize_rightTail", "clusterSize (right tail of time residual);cluster size;# entries", 100, 0, 100);
+        hClusterSize_mainPeak =
+            new TH1F("clusterSize_mainPeak", "clusterSize (main peak of time residual);cluster size;# entries", 100, 0, 100);
+        hTot_leftTail =
+            new TH1F("hTot_leftTail", "ToT (left tail of time residual);seed pixel ToT [lsb];# events", 2 * 64, -64, 64);
+        hTot_rightTail =
+            new TH1F("hTot_rightTail", "ToT (right tail of time residual);seed pixel ToT [lsb];# events", 2 * 64, -64, 64);
+        hTot_mainPeak = new TH1F("hTot_mainPeak",
+                                 "ToT (main peak of time residual, 1px clusters);seed pixel ToT [lsb];# events",
                                  2 * 64,
                                  -64,
                                  64);
-    hPixelTimestamp_leftTail = new TH1F("pixelTimestamp_leftTail",
-                                        "pixelTimestamp (left tail of time residual); pixel timestamp [ms]; # events",
-                                        3e6,
-                                        0,
-                                        3e3);
-    hPixelTimestamp_rightTail = new TH1F("pixelTimestamp_leftTail",
-                                         "pixelTimestamp (left tail of time residual); pixel timestamp [ms]; # events",
-                                         3e6,
-                                         0,
-                                         3e3);
-    hPixelTimestamp_mainPeak = new TH1F("pixelTimestamp_mainPeak",
-                                        "pixelTimestamp (left tail of time residual); pixel timestamp [ms]; # events",
-                                        3e6,
-                                        0,
-                                        3e3);
+        hTot_leftTail_1px = new TH1F("hTot_leftTail_1px",
+                                     "ToT (left tail of time residual, 1px clusters);seed pixel ToT [lsb];# events",
+                                     2 * 64,
+                                     -64,
+                                     64);
+        hTot_rightTail_1px = new TH1F("hTot_rightTail_1px",
+                                      "ToT (right tail of time residual, 1px clusters);seed pixel ToT [lsb];# events",
+                                      2 * 64,
+                                      -64,
+                                      64);
+        hTot_mainPeak_1px = new TH1F("hTot_mainPeak_1px",
+                                     "ToT (main peak of time residual, 1px clusters);seed pixel ToT [lsb];# events",
+                                     2 * 64,
+                                     -64,
+                                     64);
+        hPixelTimestamp_leftTail = new TH1F("pixelTimestamp_leftTail",
+                                            "pixelTimestamp (left tail of time residual);pixel timestamp [ms];# events",
+                                            3e6,
+                                            0,
+                                            3e3);
+        hPixelTimestamp_rightTail = new TH1F("pixelTimestamp_leftTail",
+                                             "pixelTimestamp (left tail of time residual);pixel timestamp [ms];# events",
+                                             3e6,
+                                             0,
+                                             3e3);
+        hPixelTimestamp_mainPeak = new TH1F("pixelTimestamp_mainPeak",
+                                            "pixelTimestamp (left tail of time residual);pixel timestamp [ms];# events",
+                                            3e6,
+                                            0,
+                                            3e3);
+    }
 
     // /////////////////////////////////////////// //
     // TGraphErrors for Timewalk & Row Correction: //
     // /////////////////////////////////////////// //
 
-    gTimeCorrelationVsRow = new TGraphErrors();
-    gTimeCorrelationVsRow->SetName("gTimeCorrelationVsRow");
-    gTimeCorrelationVsRow->SetTitle("gTimeCorrelationVsRow");
-    gTimeCorrelationVsRow->GetXaxis()->SetTitle("row");
-    gTimeCorrelationVsRow->GetYaxis()->SetTitle("time correlation peak [ns]");
-
-    // !!!!also fix these:!!!!
-    int nBinsToT = hTrackCorrelationTimeVsTot_rowCorr->GetNbinsY();
-    gTimeCorrelationVsTot_rowCorr = new TGraphErrors(nBinsToT);
-    gTimeCorrelationVsTot_rowCorr->SetName("gTimeCorrelationVsTot");
-    gTimeCorrelationVsTot_rowCorr->SetTitle("gTimeCorrelationVsTot");
-    gTimeCorrelationVsTot_rowCorr->GetXaxis()->SetTitle("pixel ToT [ns]");
-    gTimeCorrelationVsTot_rowCorr->GetYaxis()->SetTitle("time correlation peak [ns]");
-
-    nBinsToT = hTrackCorrelationTimeVsTot_rowCorr_1px->GetNbinsY();
-    gTimeCorrelationVsTot_rowCorr_1px = new TGraphErrors(nBinsToT);
-    gTimeCorrelationVsTot_rowCorr_1px->SetName("gTimeCorrelationVsTot_1px");
-    gTimeCorrelationVsTot_rowCorr_1px->SetTitle("gTimeCorrelationVsTot_1px");
-    gTimeCorrelationVsTot_rowCorr_1px->GetXaxis()->SetTitle("pixel ToT [ns] (single-pixel clusters)");
-    gTimeCorrelationVsTot_rowCorr_1px->GetYaxis()->SetTitle("time correlation peak [ns]");
-
-    nBinsToT = hTrackCorrelationTimeVsTot_rowCorr_npx->GetNbinsY();
-    gTimeCorrelationVsTot_rowCorr_npx = new TGraphErrors(nBinsToT);
-    gTimeCorrelationVsTot_rowCorr_npx->SetName("gTimeCorrelationVsTot_npx");
-    gTimeCorrelationVsTot_rowCorr_npx->SetTitle("gTimeCorrelationVsTot_npx");
-    gTimeCorrelationVsTot_rowCorr_npx->GetXaxis()->SetTitle("pixel ToT [ns] (multi-pixel clusters");
-    gTimeCorrelationVsTot_rowCorr_npx->GetYaxis()->SetTitle("time correlation peak [ns]");
-
-    LOG(INFO) << "calcCorrections = " << m_calcCorrections;
+    if(m_calcCorrections) {
+        gTimeCorrelationVsRow = new TGraphErrors();
+        gTimeCorrelationVsRow->SetName("gTimeCorrelationVsRow");
+        gTimeCorrelationVsRow->SetTitle("gTimeCorrelationVsRow");
+        gTimeCorrelationVsRow->GetXaxis()->SetTitle("row");
+        gTimeCorrelationVsRow->GetYaxis()->SetTitle("time correlation peak [ns]");
+
+        int nBinsToT = hTrackCorrelationTimeVsTot_rowCorr->GetNbinsY();
+        gTimeCorrelationVsTot_rowCorr = new TGraphErrors(nBinsToT);
+        gTimeCorrelationVsTot_rowCorr->SetName("gTimeCorrelationVsTot_rowCorr");
+        gTimeCorrelationVsTot_rowCorr->SetTitle("gTimeCorrelationVsTot_rowCorr");
+        gTimeCorrelationVsTot_rowCorr->GetXaxis()->SetTitle("pixel ToT [ns]");
+        gTimeCorrelationVsTot_rowCorr->GetYaxis()->SetTitle("time correlation peak [ns]");
+
+        nBinsToT = hTrackCorrelationTimeVsTot_rowCorr_1px->GetNbinsY();
+        gTimeCorrelationVsTot_rowCorr_1px = new TGraphErrors(nBinsToT);
+        gTimeCorrelationVsTot_rowCorr_1px->SetName("gTimeCorrelationVsTot_rowCorr_1px");
+        gTimeCorrelationVsTot_rowCorr_1px->SetTitle("gTimeCorrelationVsTot_rowCorr_1px");
+        gTimeCorrelationVsTot_rowCorr_1px->GetXaxis()->SetTitle("pixel ToT [ns] (single-pixel clusters)");
+        gTimeCorrelationVsTot_rowCorr_1px->GetYaxis()->SetTitle("time correlation peak [ns]");
+
+        nBinsToT = hTrackCorrelationTimeVsTot_rowCorr_npx->GetNbinsY();
+        gTimeCorrelationVsTot_rowCorr_npx = new TGraphErrors(nBinsToT);
+        gTimeCorrelationVsTot_rowCorr_npx->SetName("gTimeCorrelationVsTot_rowCorr_npx");
+        gTimeCorrelationVsTot_rowCorr_npx->SetTitle("gTimeCorrelationVsTot_rowCorr_npx");
+        gTimeCorrelationVsTot_rowCorr_npx->GetXaxis()->SetTitle("pixel ToT [ns] (multi-pixel clusters");
+        gTimeCorrelationVsTot_rowCorr_npx->GetYaxis()->SetTitle("time correlation peak [ns]");
+    }
+
+    LOG(INFO) << "Calculate corrections: = " << m_calcCorrections;
 
     if(m_pointwise_correction_row) {
         // Import TGraphErrors for row corection:
@@ -602,8 +630,8 @@ StatusCode AnalysisTimingATLASpix::run(std::shared_ptr<Clipboard> clipboard) {
                     auto xmod = static_cast<double>(Units::convert(inpixel.X(), "um"));
                     auto ymod = static_cast<double>(Units::convert(inpixel.Y(), "um"));
                     hHitMapAssoc_inPixel->Fill(xmod, ymod);
-                    if(cluster->charge() > m_highChargeCut && cluster->size() == 1) {
-                        hHitMapAssoc_inPixel_highCharge->Fill(xmod, ymod);
+                    if(m_config.has("high_tot_cut") && cluster->charge() > m_highTotCut && cluster->size() == 1) {
+                        hHitMapAssoc_inPixel_highToT->Fill(xmod, ymod);
                     }
                     hPixelTrackCorrelationTimeMap->Fill(xmod, ymod, timeDiff);
 
@@ -618,19 +646,21 @@ StatusCode AnalysisTimingATLASpix::run(std::shared_ptr<Clipboard> clipboard) {
                         hClusterSizeVsTot_Assoc->Fill(static_cast<double>(cluster->size()), pixel->raw());
                         hHitMapAssoc->Fill(pixel->column(), pixel->row());
                         hTotVsTime->Fill(pixel->raw(), static_cast<double>(Units::convert(pixel->timestamp(), "s")));
-                        if(pixel->raw() > m_highTotCut) {
-                            hHitMapAssoc_highCharge->Fill(pixel->column(), pixel->row());
+                        if(m_config.has("high_tot_cut") && pixel->raw() > m_highTotCut) {
+                            hHitMapAssoc_highToT->Fill(pixel->column(), pixel->row());
                             hTotVsTime_high->Fill(pixel->raw(),
                                                   static_cast<double>(Units::convert(pixel->timestamp(), "s")));
                         }
                     }
                     hClusterMapAssoc->Fill(cluster->column(), cluster->row());
-                    if(track->timestamp() - cluster->timestamp() < m_leftTailCut) {
-                        hInPixelMap_leftTail->Fill(xmod, ymod);
-                    } else if(track->timestamp() - cluster->timestamp() > m_rightTailCut) {
-                        hInPixelMap_rightTail->Fill(xmod, ymod);
-                    } else {
-                        hInPixelMap_mainPeak->Fill(xmod, ymod);
+                    if(m_config.has("timing_tail_cut") && m_pointwise_correction_timewalk) {
+                        if(track->timestamp() - cluster->timestamp() < -m_timingTailCut) {
+                            hInPixelMap_leftTail->Fill(xmod, ymod);
+                        } else if(track->timestamp() - cluster->timestamp() > m_timingTailCut) {
+                            hInPixelMap_rightTail->Fill(xmod, ymod);
+                        } else {
+                            hInPixelMap_mainPeak->Fill(xmod, ymod);
+                        }
                     }
 
                     // !!! Have to do this in the end because it changes the cluster time and position!!!
@@ -658,46 +688,48 @@ StatusCode AnalysisTimingATLASpix::run(std::shared_ptr<Clipboard> clipboard) {
                     // point-wise timewalk correction on top:
                     if(m_pointwise_correction_timewalk) {
                         correctClusterTimestamp(cluster, 1); // mode=1 --> timewalk correction
-                        hTrackCorrelationTime_rowAndTimeWalkCorr->Fill(track->timestamp() - cluster->timestamp());
+                        hTrackCorrelationTime_rowAndTWCorr->Fill(track->timestamp() - cluster->timestamp());
                         if(cluster->getSeedPixel()->raw() < 25) {
-                            hTrackCorrelationTime_rowAndTimeWalkCorr_l25->Fill(track->timestamp() - cluster->timestamp());
+                            hTrackCorrelationTime_rowAndTWCorr_l25->Fill(track->timestamp() - cluster->timestamp());
                         }
                         if(cluster->getSeedPixel()->raw() < 40) {
-                            hTrackCorrelationTime_rowAndTimeWalkCorr_l40->Fill(track->timestamp() - cluster->timestamp());
+                            hTrackCorrelationTime_rowAndTWCorr_l40->Fill(track->timestamp() - cluster->timestamp());
                         }
                         if(cluster->getSeedPixel()->raw() > 40) {
-                            hTrackCorrelationTime_rowAndTimeWalkCorr_g40->Fill(track->timestamp() - cluster->timestamp());
+                            hTrackCorrelationTime_rowAndTWCorr_g40->Fill(track->timestamp() - cluster->timestamp());
                         }
 
-                        hTrackCorrelationTimeVsRow_rowAndTimeWalkCorr->Fill(
+                        hTrackCorrelationTimeVsRow_rowAndTWCorr->Fill(
                             track->timestamp() - cluster->getSeedPixel()->timestamp(), cluster->getSeedPixel()->row());
-                        hTrackCorrelationTimeVsTot_rowAndTimeWalkCorr->Fill(
+                        hTrackCorrelationTimeVsTot_rowAndTWCorr->Fill(
                             track->timestamp() - cluster->getSeedPixel()->timestamp(), cluster->getSeedPixel()->raw());
 
                         // control plots to investigate "left/right tail" in time correlation:
-                        if(track->timestamp() - cluster->timestamp() < m_leftTailCut) {
-                            hClusterMap_leftTail->Fill(cluster->column(), cluster->row());
-                            hTot_leftTail->Fill(cluster->getSeedPixel()->raw());
-                            hPixelTimestamp_leftTail->Fill(cluster->getSeedPixel()->timestamp());
-                            hClusterSize_leftTail->Fill(static_cast<double>(cluster->size()));
-                            if(cluster->size() == 1) {
-                                hTot_leftTail_1px->Fill(cluster->getSeedPixel()->raw());
-                            }
-                        } else if(track->timestamp() - cluster->timestamp() > m_rightTailCut) {
-                            hClusterMap_rightTail->Fill(cluster->column(), cluster->row());
-                            hTot_rightTail->Fill(cluster->getSeedPixel()->raw());
-                            hPixelTimestamp_rightTail->Fill(cluster->getSeedPixel()->timestamp());
-                            hClusterSize_rightTail->Fill(static_cast<double>(cluster->size()));
-                            if(cluster->size() == 1) {
-                                hTot_rightTail_1px->Fill(cluster->getSeedPixel()->raw());
-                            }
-                        } else {
-                            hClusterMap_mainPeak->Fill(cluster->column(), cluster->row());
-                            hTot_mainPeak->Fill(cluster->getSeedPixel()->raw());
-                            hPixelTimestamp_mainPeak->Fill(cluster->getSeedPixel()->timestamp());
-                            hClusterSize_mainPeak->Fill(static_cast<double>(cluster->size()));
-                            if(cluster->size() == 1) {
-                                hTot_mainPeak_1px->Fill(cluster->getSeedPixel()->raw());
+                        if(m_config.has("timing_tail_cut")) {
+                            if(track->timestamp() - cluster->timestamp() < -m_timingTailCut) {
+                                hClusterMap_leftTail->Fill(cluster->column(), cluster->row());
+                                hTot_leftTail->Fill(cluster->getSeedPixel()->raw());
+                                hPixelTimestamp_leftTail->Fill(cluster->getSeedPixel()->timestamp());
+                                hClusterSize_leftTail->Fill(static_cast<double>(cluster->size()));
+                                if(cluster->size() == 1) {
+                                    hTot_leftTail_1px->Fill(cluster->getSeedPixel()->raw());
+                                }
+                            } else if(track->timestamp() - cluster->timestamp() > m_timingTailCut) {
+                                hClusterMap_rightTail->Fill(cluster->column(), cluster->row());
+                                hTot_rightTail->Fill(cluster->getSeedPixel()->raw());
+                                hPixelTimestamp_rightTail->Fill(cluster->getSeedPixel()->timestamp());
+                                hClusterSize_rightTail->Fill(static_cast<double>(cluster->size()));
+                                if(cluster->size() == 1) {
+                                    hTot_rightTail_1px->Fill(cluster->getSeedPixel()->raw());
+                                }
+                            } else {
+                                hClusterMap_mainPeak->Fill(cluster->column(), cluster->row());
+                                hTot_mainPeak->Fill(cluster->getSeedPixel()->raw());
+                                hPixelTimestamp_mainPeak->Fill(cluster->getSeedPixel()->timestamp());
+                                hClusterSize_mainPeak->Fill(static_cast<double>(cluster->size()));
+                                if(cluster->size() == 1) {
+                                    hTot_mainPeak_1px->Fill(cluster->getSeedPixel()->raw());
+                                }
                             }
                         }
                     }
@@ -864,28 +896,28 @@ void AnalysisTimingATLASpix::finalise() {
 
         /// END TIME WALK CORRECTION ///
 
+        // Example Slice to investigate quality of Gaussian fit:
+        hTrackCorrelationTime_example = hTrackCorrelationTimeVsTot_rowCorr->ProjectionX(
+            ("hTrackCorrelationTime_totBin_" + std::to_string(m_totBinExample)).c_str(),
+            m_totBinExample,
+            m_totBinExample + 1);
+
+        binMax = hTrackCorrelationTime_example->GetMaximumBin();
+        timePeak = hTrackCorrelationTime_example->GetXaxis()->GetBinCenter(binMax);
+
+        TF1* fPeak = new TF1("fPeak", "gaus");
+        fPeak->SetParameters(1, 100, 45);
+        double timeInt = 50;
+        fitOption = "q"; // set to "q" = quiet for suppressed terminial output
+        hTrackCorrelationTime_example->Fit("fPeak", fitOption.c_str(), "", timePeak - timeInt, timePeak + timeInt);
+        delete fPeak;
+
+        gTimeCorrelationVsRow->Write();
+        gTimeCorrelationVsTot_rowCorr->Write();
+        gTimeCorrelationVsTot_rowCorr_1px->Write();
+        gTimeCorrelationVsTot_rowCorr_npx->Write();
     } // if(m_calcCorrections)
 
-    // Example Slice to investigate quality of Gaussian fit:
-    hTrackCorrelationTime_example = hTrackCorrelationTimeVsTot_rowCorr->ProjectionX(
-        ("hTrackCorrelationTime_totBin_" + std::to_string(m_totBinExample)).c_str(), m_totBinExample, m_totBinExample + 1);
-
-    int binMax = hTrackCorrelationTime_example->GetMaximumBin();
-    double timePeak = hTrackCorrelationTime_example->GetXaxis()->GetBinCenter(binMax);
-
-    TF1* fPeak = new TF1("fPeak", "gaus");
-    fPeak->SetParameters(1, 100, 45);
-    double timeInt = 50;
-    std::string fitOption = "q"; // set to "q" = quiet for suppressed terminial output
-    hTrackCorrelationTime_example->Fit("fPeak", fitOption.c_str(), "", timePeak - timeInt, timePeak + timeInt);
-    delete fPeak;
-
-    // hTrackCorrelationTime_example->Write();
-    gTimeCorrelationVsRow->Write();
-    gTimeCorrelationVsTot_rowCorr->Write();
-    gTimeCorrelationVsTot_rowCorr_1px->Write();
-    gTimeCorrelationVsTot_rowCorr_npx->Write();
-
     LOG(INFO) << "matched/total tracks: " << matched_tracks << "/" << total_tracks;
     LOG(INFO) << "total tracks (uncut):\t" << total_tracks_uncut;
     LOG(INFO) << "after chi2 cut:\t" << tracks_afterChi2Cut;
diff --git a/src/modules/AnalysisTimingATLASpix/AnalysisTimingATLASpix.h b/src/modules/AnalysisTimingATLASpix/AnalysisTimingATLASpix.h
index d340cd928..b193c2055 100644
--- a/src/modules/AnalysisTimingATLASpix/AnalysisTimingATLASpix.h
+++ b/src/modules/AnalysisTimingATLASpix/AnalysisTimingATLASpix.h
@@ -46,10 +46,10 @@ namespace corryvreckan {
         TH1F* hTrackCorrelationTime;
         TH1F* hTrackCorrelationTimeAssoc;
         TH1F* hTrackCorrelationTime_rowCorr;
-        TH1F* hTrackCorrelationTime_rowAndTimeWalkCorr;
-        TH1F* hTrackCorrelationTime_rowAndTimeWalkCorr_l25;
-        TH1F* hTrackCorrelationTime_rowAndTimeWalkCorr_l40;
-        TH1F* hTrackCorrelationTime_rowAndTimeWalkCorr_g40;
+        TH1F* hTrackCorrelationTime_rowAndTWCorr;
+        TH1F* hTrackCorrelationTime_rowAndTWCorr_l25;
+        TH1F* hTrackCorrelationTime_rowAndTWCorr_l40;
+        TH1F* hTrackCorrelationTime_rowAndTWCorr_g40;
         TH1D* hTrackCorrelationTime_example;
         TH1F* hClusterTimeMinusPixelTime;
 
@@ -66,17 +66,17 @@ namespace corryvreckan {
         TH2F* hTrackCorrelationTimeVsTot_rowCorr;
         TH2F* hTrackCorrelationTimeVsTot_rowCorr_1px;
         TH2F* hTrackCorrelationTimeVsTot_rowCorr_npx;
-        TH2F* hTrackCorrelationTimeVsRow_rowAndTimeWalkCorr;
-        TH2F* hTrackCorrelationTimeVsTot_rowAndTimeWalkCorr;
+        TH2F* hTrackCorrelationTimeVsRow_rowAndTWCorr;
+        TH2F* hTrackCorrelationTimeVsTot_rowAndTWCorr;
 
         TProfile2D* hPixelTrackCorrelationTimeMap;
 
         TH2F* hClusterSizeVsTot_Assoc;
 
         TH2F* hHitMapAssoc;
-        TH2F* hHitMapAssoc_highCharge;
+        TH2F* hHitMapAssoc_highToT;
         TH2F* hHitMapAssoc_inPixel;
-        TH2F* hHitMapAssoc_inPixel_highCharge;
+        TH2F* hHitMapAssoc_inPixel_highToT;
         TH2F* hClusterMapAssoc;
 
         TH2F* hTotVsRow;
@@ -120,11 +120,9 @@ namespace corryvreckan {
         double m_timeCutFrameEdge;
         double m_clusterChargeCut;
         size_t m_clusterSizeCut;
-        int m_highTotCut;       // for pixel->tot()
-        int m_lowTotCut;        // for pixel->tot()
-        double m_highChargeCut; // for cluster->charge()
-        double m_leftTailCut;
-        double m_rightTailCut;
+        int m_highTotCut; // for pixel->tot()
+        int m_lowTotCut;  // for pixel->tot()
+        double m_timingTailCut;
 
         std::string m_correctionFile_row;
         std::string m_correctionGraph_row;
@@ -134,7 +132,7 @@ namespace corryvreckan {
         bool m_pointwise_correction_row;
         bool m_pointwise_correction_timewalk;
         int m_totBinExample;
-        double m_inpixelBinSize;
+        XYVector m_inpixelBinSize;
 
         int total_tracks_uncut;
         int tracks_afterChi2Cut;
-- 
GitLab