Commit 0a057690 authored by Simon Spannagel's avatar Simon Spannagel
Browse files

Merge branch 'rename_pixelToT_to_pixelValue' into 'master'

Changing Pixel object: renaming "tot" to "value"

See merge request !99
parents 784c4be7 3b3c4815
Pipeline #862087 passed with stages
in 18 minutes and 4 seconds
......@@ -50,7 +50,7 @@ void AnalysisCLICpix::initialise() {
0,
maxcounter - 1);
hClusterSizeAll = new TH1F("hClusterSizeAll", "hClusterSizeAll", 20, 0, 20);
hClusterTOTAll = new TH1F("hClusterTOTAll", "hClusterTOTAll", 50, 0, 50);
hClusterChargeAll = new TH1F("hClusterChargeAll", "hClusterChargeAll", 50, 0, 50);
hClustersPerEvent = new TH1F("hClustersPerEvent", "hClustersPerEvent", 500, 0, 500);
hClustersVersusEventNo = new TH1F("hClustersVersusEventNo", "hClustersVersusEventNo", 60000, 0, 60000);
hGlobalClusterPositions = new TH2F("hGlobalClusterPositions", "hGlobalClusterPositions", 200, -2.0, 2.0, 300, -1., 2);
......@@ -108,11 +108,11 @@ void AnalysisCLICpix::initialise() {
hClusterWidthRowAssociated = new TH1F("hClusterWidthRowAssociated", "hClusterWidthRowAssociated", 20, 0, 20);
hClusterWidthColAssociated = new TH1F("hClusterWidthColAssociated", "hClusterWidthColAssociated", 20, 0, 20);
hClusterTOTAssociated = new TH1F("hClusterTOTAssociated", "hClusterTOTAssociated", 50, 0, 50);
hClusterTOTAssociated1pix = new TH1F("hClusterTOTAssociated1pix", "hClusterTOTAssociated1pix", 50, 0, 50);
hClusterTOTAssociated2pix = new TH1F("hClusterTOTAssociated2pix", "hClusterTOTAssociated2pix", 50, 0, 50);
hClusterTOTAssociated3pix = new TH1F("hClusterTOTAssociated3pix", "hClusterTOTAssociated3pix", 50, 0, 50);
hClusterTOTAssociated4pix = new TH1F("hClusterTOTAssociated4pix", "hClusterTOTAssociated4pix", 50, 0, 50);
hClusterChargeAssociated = new TH1F("hClusterChargeAssociated", "hClusterChargeAssociated", 50, 0, 50);
hClusterChargeAssociated1pix = new TH1F("hClusterChargeAssociated1pix", "hClusterChargeAssociated1pix", 50, 0, 50);
hClusterChargeAssociated2pix = new TH1F("hClusterChargeAssociated2pix", "hClusterChargeAssociated2pix", 50, 0, 50);
hClusterChargeAssociated3pix = new TH1F("hClusterChargeAssociated3pix", "hClusterChargeAssociated3pix", 50, 0, 50);
hClusterChargeAssociated4pix = new TH1F("hClusterChargeAssociated4pix", "hClusterChargeAssociated4pix", 50, 0, 50);
hPixelResponseX = new TH1F("hPixelResponseX", "hPixelResponseX", 600, -0.3, 0.3);
hPixelResponseY = new TH1F("hPixelResponseY", "hPixelResponseY", 600, -0.3, 0.3);
......@@ -130,10 +130,10 @@ void AnalysisCLICpix::initialise() {
hResidualsLocalRow2pix = new TH1F("hResidualsLocalRow2pix", "hResidualsLocalRow2pix", 600, -0.3, 0.3);
hResidualsLocalCol2pix = new TH1F("hResidualsLocalCol2pix", "hResidualsLocalCol2pix", 600, -0.3, 0.3);
hClusterTOTRow2pix = new TH1F("hClusterTOTRow2pix", "hClusterTOTRow2pix", 50, 0, 50);
hClusterTOTCol2pix = new TH1F("hClusterTOTCol2pix", "hClusterTOTCol2pix", 50, 0, 50);
hClusterTOTRatioRow2pix = new TH1F("hClusterTOTRatioRow2pix", "hClusterTOTRatioRow2pix", 100, 0, 1);
hClusterTOTRatioCol2pix = new TH1F("hClusterTOTRatioCol2pix", "hClusterTOTRatioCol2pix", 100, 0, 1);
hClusterChargeRow2pix = new TH1F("hClusterChargeRow2pix", "hClusterChargeRow2pix", 50, 0, 50);
hClusterChargeCol2pix = new TH1F("hClusterChargeCol2pix", "hClusterChargeCol2pix", 50, 0, 50);
hClusterChargeRatioRow2pix = new TH1F("hClusterChargeRatioRow2pix", "hClusterChargeRatioRow2pix", 100, 0, 1);
hClusterChargeRatioCol2pix = new TH1F("hClusterChargeRatioCol2pix", "hClusterChargeRatioCol2pix", 100, 0, 1);
hPixelTOTRow2pix = new TH1F("hPixelTOTRow2pix", "hPixelTOTRow2pix", 50, 0, 50);
hPixelTOTCol2pix = new TH1F("hPixelTOTCol2pix", "hPixelTOTCol2pix", 50, 0, 50);
......@@ -209,9 +209,9 @@ void AnalysisCLICpix::initialise() {
for(int x = 0; x < m_nBinsX; x++) {
for(int y = 0; y < m_nBinsY; y++) {
int id = x + y * m_nBinsX;
std::string name = "hMapClusterTOTAssociated1pix" + convertToString(id);
TH1F* hMapEntryClusterTOTAssociated1pix = new TH1F(name.c_str(), name.c_str(), 50, 0, 50);
hMapClusterTOTAssociated1pix[id] = hMapEntryClusterTOTAssociated1pix;
std::string name = "hMapClusterChargeAssociated1pix" + convertToString(id);
TH1F* hMapEntryClusterChargeAssociated1pix = new TH1F(name.c_str(), name.c_str(), 50, 0, 50);
hMapClusterChargeAssociated1pix[id] = hMapEntryClusterChargeAssociated1pix;
}
}
}
......@@ -362,35 +362,35 @@ StatusCode AnalysisCLICpix::run(std::shared_ptr<Clipboard> clipboard) {
pixelInterceptX, pixelInterceptY, sqrt(xresidualBest * xresidualBest + yresidualBest * yresidualBest));
hXresidualVersusYresidual->Fill(xresidualBest, yresidualBest);
hAbsoluteResiduals->Fill(sqrt(xresidualBest * xresidualBest + yresidualBest * yresidualBest));
hClusterTOTAssociated->Fill((bestCluster)->tot());
hClusterChargeAssociated->Fill((bestCluster)->charge());
hClusterSizeAssociated->Fill(static_cast<double>(bestCluster->size()));
// hClusterWidthColAssociated->Fill((*bestCluster)->colWidth());
// hClusterWidthRowAssociated->Fill((*bestCluster)->rowWidth());
hMapClusterSizeAssociated->Fill(chipInterceptCol, chipInterceptRow, (bestCluster)->tot());
hMapClusterSizeAssociated->Fill(chipInterceptCol, chipInterceptRow, (bestCluster)->charge());
if((bestCluster)->size() == 1) {
hClusterTOTAssociated1pix->Fill((bestCluster)->tot());
hClusterChargeAssociated1pix->Fill((bestCluster)->charge());
hInterceptClusterSize1->Fill(pixelInterceptX, pixelInterceptY);
int id = static_cast<int>(floor(chipInterceptCol * m_nBinsX / m_detector->nPixels().X()) +
floor(chipInterceptRow * m_nBinsY / m_detector->nPixels().Y()) * m_nBinsX);
hMapClusterTOTAssociated1pix[id]->Fill((bestCluster)->tot());
hMapClusterChargeAssociated1pix[id]->Fill((bestCluster)->charge());
}
if((bestCluster)->size() == 2) {
hClusterTOTAssociated2pix->Fill((bestCluster)->tot());
hClusterChargeAssociated2pix->Fill((bestCluster)->charge());
hInterceptClusterSize2->Fill(pixelInterceptX, pixelInterceptY);
}
if((bestCluster)->size() == 3) {
hClusterTOTAssociated3pix->Fill((bestCluster)->tot());
hClusterChargeAssociated3pix->Fill((bestCluster)->charge());
hInterceptClusterSize3->Fill(pixelInterceptX, pixelInterceptY);
}
if((bestCluster)->size() == 4) {
hClusterTOTAssociated4pix->Fill((bestCluster)->tot());
hClusterChargeAssociated4pix->Fill((bestCluster)->charge());
hInterceptClusterSize4->Fill(pixelInterceptX, pixelInterceptY);
}
Pixels* pixels = bestCluster->pixels();
for(auto& pixel : (*pixels)) {
hPixelToTMap->Fill(pixel->column(), pixel->row(), pixel->adc());
hPixelToTMap->Fill(pixel->column(), pixel->row(), pixel->raw());
}
} else {
......@@ -546,13 +546,13 @@ void AnalysisCLICpix::fillClusterHistos(Clusters* clusters) {
for(itp = pixels->begin(); itp != pixels->end(); itp++) {
// Check if this clicpix frame is still the current
int pixelID = (*itp)->column() + nCols * (*itp)->row();
if(m_hitPixels[pixelID] != (*itp)->adc()) {
if(m_hitPixels[pixelID] != (*itp)->raw()) {
// New frame! Reset the stored pixels and trigger number
if(!newFrame) {
m_hitPixels.clear();
newFrame = true;
}
m_hitPixels[pixelID] = (*itp)->adc();
m_hitPixels[pixelID] = (*itp)->raw();
m_triggerNumber = 0;
}
hHitPixels->Fill((*itp)->column(), (*itp)->row());
......@@ -562,7 +562,7 @@ void AnalysisCLICpix::fillClusterHistos(Clusters* clusters) {
// Fill cluster histograms
hClusterSizeAll->Fill(static_cast<double>((*itc)->size()));
hClusterTOTAll->Fill((*itc)->tot());
hClusterChargeAll->Fill((*itc)->charge());
hGlobalClusterPositions->Fill((*itc)->global().x(), (*itc)->global().y());
}
......
......@@ -36,7 +36,7 @@ namespace corryvreckan {
TH1F* hRowHits;
TH1F* hClusterSizeAll;
TH1F* hClusterTOTAll;
TH1F* hClusterChargeAll;
TH1F* hClustersPerEvent;
TH1F* hClustersVersusEventNo;
TH1F* hClusterWidthRow;
......@@ -71,11 +71,11 @@ namespace corryvreckan {
TH1F* hClusterSizeAssociated;
TH1F* hClusterWidthRowAssociated;
TH1F* hClusterWidthColAssociated;
TH1F* hClusterTOTAssociated;
TH1F* hClusterTOTAssociated1pix;
TH1F* hClusterTOTAssociated2pix;
TH1F* hClusterTOTAssociated3pix;
TH1F* hClusterTOTAssociated4pix;
TH1F* hClusterChargeAssociated;
TH1F* hClusterChargeAssociated1pix;
TH1F* hClusterChargeAssociated2pix;
TH1F* hClusterChargeAssociated3pix;
TH1F* hClusterChargeAssociated4pix;
TH1F* hPixelResponseX;
TH1F* hPixelResponseGlobalX;
TH1F* hPixelResponseXOddCol;
......@@ -88,12 +88,12 @@ namespace corryvreckan {
TH2F* hEtaDistributionY;
TH1F* hResidualsLocalRow2pix;
TH1F* hResidualsLocalCol2pix;
TH1F* hClusterTOTRow2pix;
TH1F* hClusterTOTCol2pix;
TH1F* hClusterChargeRow2pix;
TH1F* hClusterChargeCol2pix;
TH1F* hPixelTOTRow2pix;
TH1F* hPixelTOTCol2pix;
TH1F* hClusterTOTRatioRow2pix;
TH1F* hClusterTOTRatioCol2pix;
TH1F* hClusterChargeRatioRow2pix;
TH1F* hClusterChargeRatioCol2pix;
// Maps
TH2F* hTrackIntercepts;
......@@ -118,7 +118,7 @@ namespace corryvreckan {
TH2F* hMapClusterSizeAssociated;
int m_nBinsX;
int m_nBinsY;
std::map<int, TH1F*> hMapClusterTOTAssociated1pix;
std::map<int, TH1F*> hMapClusterChargeAssociated1pix;
// Member variables
int m_eventNumber;
......
......@@ -13,20 +13,20 @@ This module associates CLICpix2 DUT clusters to tracks using a spatial cut (devi
* `timepix3_telescope`: Boolean to set whether the Timepix3 telescope is being used. Default value is `false`.
### Plots produced
The following plots are produced:
The following plots are produced: (Quite many of them are not filled currently!)
* 2D hitmap
* Column hits histogram
* Row hits histogram
* Cluster size histogram
* CLuster ToT histogram
* Cluster charge histogram
* Clusters per event histogram
* Clusters vs event number
* Cluster width histogram (rows, Y-axis)
* Cluster width histogram (columns, X-axis)
* Global track difference
* Global track difference in X
* Global track difference in Y
* Global residuals in X
* Global residuals in Y
......@@ -55,10 +55,10 @@ The following plots are produced:
* Associated cluster size
* Associated cluster width (row)
* Associated cluster width (column)
* Associated 1-pixel cluster ToT
* Associated 2-pixel cluster ToT
* Associated 3-pixel cluster ToT
* Associated 4-pixel cluster ToT
* Associated 1-pixel cluster charge
* Associated 2-pixel cluster charge
* Associated 3-pixel cluster charge
* Associated 4-pixel cluster charge
* Pixel response in X
* Pixel response in X in global coordinates
* Pixel response in X for odd columns
......@@ -72,12 +72,12 @@ The following plots are produced:
* Local residual for rows for 2-pixel clusters
* Local residual for columns for 2-pixel clusters
* Cluster ToT for rows for 2-pixel clusters
* Cluster ToT for columns for 2-pixel clusters
* Cluster charge for rows for 2-pixel clusters
* Cluster charge for columns for 2-pixel clusters
* Pixel ToT for rows for 2-pixel clusters
* Pixel ToT for columns for 2-pixel clusters
* Cluster ToT ratio for rows for 2-pixel clusters
* Cluster ToT ratio for rows for 2-pixel clusters
* Cluster charge ratio for rows for 2-pixel clusters
* Cluster charge ratio for rows for 2-pixel clusters
* Local residuals for rows for 2-pixel clusters
* 2D track intercepts
......
......@@ -17,7 +17,7 @@ AnalysisDUT::AnalysisDUT(Configuration config, std::shared_ptr<Detector> detecto
void AnalysisDUT::initialise() {
hClusterMapAssoc = new TH2F("clusterMapAssoc",
"clusterMapAssoc",
"clusterMapAssoc; cluster col; cluster row",
m_detector->nPixels().X(),
0,
m_detector->nPixels().X(),
......@@ -25,7 +25,7 @@ void AnalysisDUT::initialise() {
0,
m_detector->nPixels().Y());
hClusterSizeMapAssoc = new TProfile2D("clusterSizeMapAssoc",
"clusterSizeMapAssoc",
"clusterSizeMapAssoc; cluster size; #entries",
m_detector->nPixels().X(),
0,
m_detector->nPixels().X(),
......@@ -34,21 +34,20 @@ void AnalysisDUT::initialise() {
m_detector->nPixels().Y(),
0,
100);
hClusterToTMapAssoc = new TProfile2D("clusterSizeToTAssoc",
"clusterToTMapAssoc",
m_detector->nPixels().X(),
0,
m_detector->nPixels().X(),
m_detector->nPixels().Y(),
0,
m_detector->nPixels().Y(),
0,
1000);
hClusterChargeMapAssoc = new TProfile2D("clusterChargeMapAssoc",
"clusterSizeChargeAssoc; cluster charge [e]; #entries",
m_detector->nPixels().X(),
0,
m_detector->nPixels().X(),
m_detector->nPixels().Y(),
0,
m_detector->nPixels().Y(),
0,
500);
// Per-pixel histograms
hHitMapAssoc = new TH2F("hitMapAssoc",
"hitMapAssoc",
"hitMapAssoc; hit column; hit row",
m_detector->nPixels().X(),
0,
m_detector->nPixels().X(),
......@@ -56,24 +55,24 @@ void AnalysisDUT::initialise() {
0,
m_detector->nPixels().Y());
hHitMapROI = new TH2F("hitMapROI",
"hitMapROI",
"hitMapROI; hit column; hit row",
m_detector->nPixels().X(),
0,
m_detector->nPixels().X(),
m_detector->nPixels().Y(),
0,
m_detector->nPixels().Y());
hPixelToTAssoc = new TH1F("pixelToTAssoc", "pixelToTAssoc", 32, 0, 31);
hPixelToTMapAssoc = new TProfile2D("pixelToTMapAssoc",
"pixelToTMapAssoc",
m_detector->nPixels().X(),
0,
m_detector->nPixels().X(),
m_detector->nPixels().Y(),
0,
m_detector->nPixels().Y(),
0,
255);
hPixelRawValueAssoc = new TH1F("pixelRawValueAssoc", "pixelRawValueAssoc", 32, 0, 31);
hPixelRawValueMapAssoc = new TProfile2D("pixelRawValueMapAssoc",
"pixelRawValueMapAssoc",
m_detector->nPixels().X(),
0,
m_detector->nPixels().X(),
m_detector->nPixels().Y(),
0,
m_detector->nPixels().Y(),
0,
255);
associatedTracksVersusTime = new TH1F("associatedTracksVersusTime", "associatedTracksVersusTime", 300000, 0, 300);
residualsX = new TH1F("residualsX", "residualsX", 800, -0.1, 0.1);
......@@ -84,8 +83,7 @@ void AnalysisDUT::initialise() {
residualsX2pix = new TH1F("residualsX2pix", "residualsX2pix", 400, -0.2, 0.2);
residualsY2pix = new TH1F("residualsY2pix", "residualsY2pix", 400, -0.2, 0.2);
clusterTotAssoc = new TH1F("clusterTotAssociated", "clusterTotAssociated", 10000, 0, 10000);
clusterTotAssocNorm = new TH1F("clusterTotAssociatedNormalized", "clusterTotAssociatedNormalized", 10000, 0, 10000);
clusterChargeAssoc = new TH1F("clusterChargeAssociated", "clusterChargeAssociated [e]", 10000, 0, 10000);
clusterSizeAssoc = new TH1F("clusterSizeAssociated", "clusterSizeAssociated", 30, 0, 30);
clusterSizeAssocNorm = new TH1F("clusterSizeAssociatedNormalized", "clusterSizeAssociatedNormalized", 30, 0, 30);
......@@ -305,15 +303,16 @@ StatusCode AnalysisDUT::run(std::shared_ptr<Clipboard> clipboard) {
hClusterSizeMapAssoc->Fill(m_detector->getColumn(clusterLocal),
m_detector->getRow(clusterLocal),
static_cast<double>(cluster->size()));
hClusterToTMapAssoc->Fill(
m_detector->getColumn(clusterLocal), m_detector->getRow(clusterLocal), cluster->tot());
clusterTotAssoc->Fill(cluster->tot());
// Cluster charge normalized to path length in sensor:
double norm = 1; // FIXME fabs(cos( turn*wt )) * fabs(cos( tilt*wt ));
auto normalized_charge = cluster->tot() * norm;
clusterTotAssocNorm->Fill(normalized_charge);
// FIXME: what does this mean? To my understanding we have the correct charge here already...
auto normalized_charge = cluster->charge() * norm;
// clusterChargeAssoc->Fill(normalized_charge);
clusterChargeAssoc->Fill(cluster->charge());
hClusterChargeMapAssoc->Fill(
m_detector->getColumn(clusterLocal), m_detector->getRow(clusterLocal), cluster->charge());
// Fill per-pixel histograms
for(auto& pixel : (*cluster->pixels())) {
......@@ -321,8 +320,8 @@ StatusCode AnalysisDUT::run(std::shared_ptr<Clipboard> clipboard) {
if(is_within_roi) {
hHitMapROI->Fill(pixel->column(), pixel->row());
}
hPixelToTAssoc->Fill(pixel->tot());
hPixelToTMapAssoc->Fill(pixel->column(), pixel->row(), pixel->tot());
hPixelRawValueAssoc->Fill(pixel->raw());
hPixelRawValueMapAssoc->Fill(pixel->column(), pixel->row(), pixel->raw());
}
associatedTracksVersusTime->Fill(static_cast<double>(Units::convert(track->timestamp(), "s")));
......@@ -343,14 +342,14 @@ StatusCode AnalysisDUT::run(std::shared_ptr<Clipboard> clipboard) {
// Time residuals
residualsTime->Fill(tdistance);
residualsTimeVsTime->Fill(tdistance, track->timestamp());
residualsTimeVsSignal->Fill(tdistance, cluster->tot());
residualsTimeVsSignal->Fill(tdistance, cluster->charge());
clusterSizeAssoc->Fill(static_cast<double>(cluster->size()));
clusterSizeAssocNorm->Fill(static_cast<double>(cluster->size()));
// Fill in-pixel plots: (all as function of track position within pixel cell)
if(is_within_roi) {
qvsxmym->Fill(xmod, ymod, cluster->tot()); // cluster charge profile
qvsxmym->Fill(xmod, ymod, cluster->charge()); // cluster charge profile
qMoyalvsxmym->Fill(xmod, ymod, exp(-normalized_charge / 3.5)); // norm. cluster charge profile
// mean charge of cluster seed
......
......@@ -28,10 +28,10 @@ namespace corryvreckan {
// Histograms
TH2F *hClusterMapAssoc, *hHitMapAssoc, *hHitMapROI;
TProfile2D *hClusterSizeMapAssoc, *hClusterToTMapAssoc;
TProfile2D *hClusterSizeMapAssoc, *hClusterChargeMapAssoc;
TH1F* hPixelToTAssoc;
TProfile2D* hPixelToTMapAssoc;
TH1F* hPixelRawValueAssoc;
TProfile2D* hPixelRawValueMapAssoc;
TH1F* associatedTracksVersusTime;
TH1F *residualsX, *residualsY;
......@@ -39,7 +39,7 @@ namespace corryvreckan {
TH1F *residualsX1pix, *residualsY1pix;
TH1F *residualsX2pix, *residualsY2pix;
TH1F *clusterTotAssoc, *clusterTotAssocNorm;
TH1F* clusterChargeAssoc;
TH1F* clusterSizeAssoc;
TH1F* clusterSizeAssocNorm;
......
......@@ -5,7 +5,7 @@
**Status**: Work in progress
### Description
Analysis module for CLICpix2 prototypes. This module is still work in progress, changes to functionality and behaviour are to be expected.
Generic analysis module for all prototypes. This module is still work in progress, changes to functionality and behaviour are to be expected.
### Parameters
* `time_cut_frameedge`: Parameter to discard telescope tracks at the frame edges (start and end of the current CLICpix2 frame). Defaults to `20ns`.
......@@ -15,16 +15,16 @@ Analysis module for CLICpix2 prototypes. This module is still work in progress,
### Plots produced
* 2D Map of associated cluster positions
* 2D Map of cluster sizes for associated clusters
* 2D Map of cluster ToT values from associated clusters
* 2D Map of cluster charge values from associated clusters
* 2D Map of associated hits
* 2D Map of tracks not associated to a cluster
* 2D Map of associated hits within the defined region-of-interest
* Distribution of pixel ToT values from associated clusters
* 2D Map of pixel ToT values from associated clusters
* Distribution of pixel raw value (ToT, ADC, ...) values from associated clusters
* 2D Map of pixel raw value (ToT, ADC, ...) values from associated clusters
* Track residuals in X and Y
* Track residuals for 1-pixel-clusters in X and Y
* Track residuals for 2-pixel-clusters in X and Y
* Distribution of cluster Tot values from associated clusters
* Distribution of cluster charge values from associated clusters
* Distribution of sizes from associated clusters
* Normalised distribution of sizes from associated clusters
* 2D Map of in-pixel efficiency
......
......@@ -21,7 +21,7 @@ void Clustering4D::initialise() {
title = m_detector->name() + " Cluster Width - Columns;cluster width [columns];events";
clusterWidthColumn = new TH1F("clusterWidthColumn", title.c_str(), 100, 0, 100);
title = m_detector->name() + " Cluster Charge;cluster charge [e];events";
clusterTot = new TH1F("clusterTot", title.c_str(), 10000, 0, 100000);
clusterCharge = new TH1F("clusterCharge", title.c_str(), 10000, 0, 100000);
title = m_detector->name() + " Cluster Position (Global);x [mm];y [mm];events";
clusterPositionGlobal = new TH2F("clusterPositionGlobal", title.c_str(), 400, -10., 10., 400, -10., 10.);
}
......@@ -60,10 +60,6 @@ StatusCode Clustering4D::run(std::shared_ptr<Clipboard> clipboard) {
continue;
}
if(pixel->adc() == 0.) {
continue;
}
// Make the new cluster object
Cluster* cluster = new Cluster();
LOG(DEBUG) << "==== New cluster";
......@@ -88,9 +84,6 @@ StatusCode Clustering4D::run(std::shared_ptr<Clipboard> clipboard) {
if(used[neighbour])
continue;
if(neighbour->adc() == 0.)
continue;
// Check if they are touching cluster pixels
if(!touching(neighbour, cluster))
continue;
......@@ -111,7 +104,7 @@ StatusCode Clustering4D::run(std::shared_ptr<Clipboard> clipboard) {
clusterSize->Fill(static_cast<double>(cluster->size()));
clusterWidthRow->Fill(cluster->rowWidth());
clusterWidthColumn->Fill(cluster->columnWidth());
clusterTot->Fill(cluster->tot());
clusterCharge->Fill(cluster->charge());
clusterPositionGlobal->Fill(cluster->global().x(), cluster->global().y());
deviceClusters->push_back(cluster);
......@@ -163,30 +156,33 @@ bool Clustering4D::closeInTime(Pixel* neighbour, Cluster* cluster) {
void Clustering4D::calculateClusterCentre(Cluster* cluster) {
LOG(DEBUG) << "== Making cluster centre";
// Empty variables to calculate cluster position
double row(0), column(0), tot(0);
double column(0), row(0), charge(0);
// Get the pixels on this cluster
Pixels* pixels = cluster->pixels();
string detectorID = (*pixels)[0]->detectorID();
double timestamp = (*pixels)[0]->timestamp();
LOG(DEBUG) << "- cluster has " << (*pixels).size() << " pixels";
// Loop over all pixels
for(auto& pixel : (*pixels)) {
double pixelToT = pixel->adc();
if(pixelToT == 0) {
LOG(DEBUG) << "Pixel with ToT 0!";
pixelToT = 1;
}
tot += pixelToT;
row += (pixel->row() * pixelToT);
column += (pixel->column() * pixelToT);
if(pixel->timestamp() < timestamp)
charge += pixel->charge();
column += (pixel->column() * pixel->charge());
row += (pixel->row() * pixel->charge());
if(pixel->timestamp() < timestamp) {
timestamp = pixel->timestamp();
}
}
// Row and column positions are tot-weighted
row /= (tot > 0 ? tot : 1);
column /= (tot > 0 ? tot : 1);
// Column and row positions are charge-weighted
// If charge == 0 (use epsilon to avoid errors in floating-point arithmetics)
// calculate simple arithmetic mean
column /= (charge > std::numeric_limits<double>::epsilon() ? charge : 1);
row /= (charge > std::numeric_limits<double>::epsilon() ? charge : 1);
LOG(DEBUG) << "- cluster col, row: " << column << "," << row;
if(detectorID != m_detector->name()) {
// Should never happen...
......@@ -201,9 +197,9 @@ void Clustering4D::calculateClusterCentre(Cluster* cluster) {
PositionVector3D<Cartesian3D<double>> positionGlobal = m_detector->localToGlobal(positionLocal);
// Set the cluster parameters
cluster->setRow(row);
cluster->setColumn(column);
cluster->setTot(tot);
cluster->setRow(row);
cluster->setCharge(charge);
// Set uncertainty on position from intrinstic detector resolution:
cluster->setError(m_detector->resolution());
......
......@@ -34,7 +34,7 @@ namespace corryvreckan {
TH1F* clusterSize;
TH1F* clusterWidthRow;
TH1F* clusterWidthColumn;
TH1F* clusterTot;
TH1F* clusterCharge;
TH2F* clusterPositionGlobal;
double timingCut;
......
......@@ -5,7 +5,7 @@
**Status**: Functional
### Description
This module performs clustering on data from a Timepix3 device. The clustering method is a charge-weighted centre of gravity calculation, using a positional cut and a timing cut on proximity.
This module performs clustering for detectors with valid individual hit timestamps. The clustering method is a charge-weighted centre of gravity calculation, using a positional cut and a timing cut on proximity. If the pixel information is binary (i.e. no valid charge-equivalent information is available), the arithmetic mean is calculated for the position.
Split clusters can be recovered using a larger search radius for neighbouring pixels.
......@@ -20,7 +20,7 @@ For each detector the following plots are produced:
* Cluster size histogram
* Cluster width (rows, in X) histogram
* Cluster width (columns, in Y) histogram
* Cluster ToT histogram
* Cluster charge histogram
* 2D cluster positions in global coordinates
### Usage
......
......@@ -27,7 +27,7 @@ void ClusteringSpatial::initialise() {
title = m_detector->name() + " Cluster Width - Columns;cluster width [columns];events";
clusterWidthColumn = new TH1F("clusterWidthColumn", title.c_str(), 100, 0, 100);
title = m_detector->name() + " Cluster Charge;cluster charge [ke];events";
clusterTot = new TH1F("clusterTot", title.c_str(), 300, 0, 300);
clusterCharge = new TH1F("clusterCharge", title.c_str(), 300, 0, 300);
title = m_detector->name() + " Cluster Position (Global);x [mm];y [mm];events";
clusterPositionGlobal = new TH2F("clusterPositionGlobal",
title.c_str(),
......@@ -135,7 +135,7 @@ StatusCode ClusteringSpatial::run(std::shared_ptr<Clipboard> clipboard) {
clusterSize->Fill(static_cast<double>(cluster->size()));
clusterWidthRow->Fill(cluster->rowWidth());
clusterWidthColumn->Fill(cluster->columnWidth());
clusterTot->Fill(cluster->tot() * 1e-3);
clusterCharge->Fill(cluster->charge() * 1e-3); // 1e-3 because unit is [ke]
clusterPositionGlobal->Fill(cluster->global().x(), cluster->global().y());
clusterPositionLocal->Fill(cluster->local().x(), cluster->local().y());
LOG(DEBUG) << "cluster local: " << cluster->local();
......@@ -158,7 +158,7 @@ void ClusteringSpatial::calculateClusterCentre(Cluster* cluster) {
LOG(DEBUG) << "== Making cluster centre";
// Empty variables to calculate cluster position
double row(0), column(0), tot(0);
double column(0), row(0), charge(0);
// Get the pixels on this cluster
Pixels* pixels = cluster->pixels();
......@@ -167,15 +167,18 @@ void ClusteringSpatial::calculateClusterCentre(Cluster* cluster) {