Commit 85505a02 authored by Simon Spannagel's avatar Simon Spannagel
Browse files

Adapt to new interface of Cluster class

parent 176c6bfc
......@@ -363,7 +363,7 @@ bool Detector::isWithinROI(Cluster* cluster) const {
}
// Loop over all pixels of the cluster
for(auto& pixel : (*cluster->pixels())) {
for(auto& pixel : cluster->pixels()) {
if(winding_number(pixel->coordinates(), m_roi) == 0) {
return false;
}
......
......@@ -388,8 +388,8 @@ StatusCode AnalysisCLICpix::run(std::shared_ptr<Clipboard> clipboard) {
hClusterChargeAssociated4pix->Fill((bestCluster)->charge());
hInterceptClusterSize4->Fill(pixelInterceptX, pixelInterceptY);
}
Pixels* pixels = bestCluster->pixels();
for(auto& pixel : (*pixels)) {
auto pixels = bestCluster->pixels();
for(auto& pixel : pixels) {
hPixelToTMap->Fill(pixel->column(), pixel->row(), pixel->raw());
}
......@@ -541,23 +541,22 @@ void AnalysisCLICpix::fillClusterHistos(std::shared_ptr<Clusters> clusters) {
for(itc = clusters->begin(); itc != clusters->end(); ++itc) {
// Loop over pixels and check if there are pixels not known
Pixels* pixels = (*itc)->pixels();
Pixels::iterator itp;
for(itp = pixels->begin(); itp != pixels->end(); itp++) {
auto pixels = (*itc)->pixels();
for(auto& itp : pixels) {
// Check if this clicpix frame is still the current
int pixelID = (*itp)->column() + nCols * (*itp)->row();
if(m_hitPixels[pixelID] != (*itp)->raw()) {
int pixelID = itp->column() + nCols * itp->row();
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)->raw();
m_hitPixels[pixelID] = itp->raw();
m_triggerNumber = 0;
}
hHitPixels->Fill((*itp)->column(), (*itp)->row());
hColumnHits->Fill((*itp)->column());
hRowHits->Fill((*itp)->row());
hHitPixels->Fill(itp->column(), itp->row());
hColumnHits->Fill(itp->column());
hRowHits->Fill(itp->row());
}
// Fill cluster histograms
......@@ -578,12 +577,8 @@ void AnalysisCLICpix::fillResponseHistos(double trackInterceptX, double trackInt
// Loop over pixels in the cluster and show their distance from the track
// intercept
Pixels* pixels = cluster->pixels();
Pixels::iterator itp;
for(itp = pixels->begin(); itp != pixels->end(); itp++) {
// Get the pixel
Pixel* pixel = (*itp);
auto pixels = cluster->pixels();
for(auto& pixel : pixels) {
// Get the pixel local then global position
PositionVector3D<Cartesian3D<double>> pixelPositionLocal =
m_detector->getLocalPosition(pixel->column(), pixel->row());
......
......@@ -315,7 +315,7 @@ StatusCode AnalysisDUT::run(std::shared_ptr<Clipboard> clipboard) {
m_detector->getColumn(clusterLocal), m_detector->getRow(clusterLocal), cluster->charge());
// Fill per-pixel histograms
for(auto& pixel : (*cluster->pixels())) {
for(auto& pixel : cluster->pixels()) {
hHitMapAssoc->Fill(pixel->column(), pixel->row());
if(is_within_roi) {
hHitMapROI->Fill(pixel->column(), pixel->row());
......
......@@ -474,7 +474,7 @@ StatusCode AnalysisTimingATLASpix::run(std::shared_ptr<Clipboard> clipboard) {
}
// 2D histograms: --> fill for all pixels from cluster
for(auto& pixel : (*cluster->pixels())) {
for(auto& pixel : cluster->pixels()) {
// to check that cluster timestamp = earliest pixel timestamp
if(cluster->size() > 1) {
......@@ -752,13 +752,14 @@ void AnalysisTimingATLASpix::correctClusterTimestamp(Cluster* cluster, int mode)
*/
// Get the pixels on this cluster
Pixels* pixels = cluster->pixels();
auto pixels = cluster->pixels();
auto first_pixel = pixels.front();
double correction = 0;
if(mode == 0) {
correction = gRowCorr->Eval((*pixels)[0]->row());
correction = gRowCorr->Eval(first_pixel->row());
} else if(mode == 1) {
correction = gTimeWalkCorr->Eval((*pixels)[0]->raw());
correction = gTimeWalkCorr->Eval(first_pixel->raw());
} else {
LOG(ERROR) << "Mode " << mode << " does not exist!\n"
<< "Choose\n\t0 --> row correction \n\t1-->timewalk correction";
......@@ -766,10 +767,12 @@ void AnalysisTimingATLASpix::correctClusterTimestamp(Cluster* cluster, int mode)
}
// Initial guess for cluster timestamp:
double timestamp = (*pixels)[0]->timestamp() + correction;
double timestamp = first_pixel->timestamp() + correction;
// Loop over all pixels:
for(auto& pixel : (*pixels)) {
for(auto& pixel : pixels) {
// FIXME ugly hack
auto px = const_cast<Pixel*>(pixel);
if(mode == 0) {
correction = gRowCorr->Eval(pixel->row());
......@@ -780,7 +783,7 @@ void AnalysisTimingATLASpix::correctClusterTimestamp(Cluster* cluster, int mode)
}
// Override pixel timestamps:
pixel->setTimestamp(pixel->timestamp() + correction);
px->setTimestamp(pixel->timestamp() + correction);
// timestamp = earliest pixel:
if(pixel->timestamp() < timestamp) {
......
......@@ -122,7 +122,7 @@ bool Clustering4D::touching(Pixel* neighbour, Cluster* cluster) {
bool Touching = false;
for(auto pixel : (*cluster->pixels())) {
for(auto pixel : cluster->pixels()) {
int row_distance = abs(pixel->row() - neighbour->row());
int col_distance = abs(pixel->column() - neighbour->column());
......@@ -142,10 +142,10 @@ bool Clustering4D::closeInTime(Pixel* neighbour, Cluster* cluster) {
bool CloseInTime = false;
Pixels* pixels = cluster->pixels();
for(size_t iPix = 0; iPix < pixels->size(); iPix++) {
auto pixels = cluster->pixels();
for(auto& px : pixels) {
double timeDifference = abs(neighbour->timestamp() - (*pixels)[iPix]->timestamp());
double timeDifference = abs(neighbour->timestamp() - px->timestamp());
if(timeDifference < timingCut)
CloseInTime = true;
}
......@@ -159,13 +159,13 @@ void Clustering4D::calculateClusterCentre(Cluster* cluster) {
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";
auto pixels = cluster->pixels();
string detectorID = pixels.front()->detectorID();
double timestamp = pixels.front()->timestamp();
LOG(DEBUG) << "- cluster has " << pixels.size() << " pixels";
// Loop over all pixels
for(auto& pixel : (*pixels)) {
for(auto& pixel : pixels) {
charge += pixel->charge();
column += (pixel->column() * pixel->charge());
row += (pixel->row() * pixel->charge());
......
......@@ -161,12 +161,12 @@ void ClusteringSpatial::calculateClusterCentre(Cluster* cluster) {
double column(0), row(0), charge(0);
// Get the pixels on this cluster
Pixels* pixels = cluster->pixels();
string detectorID = (*pixels)[0]->detectorID();
LOG(DEBUG) << "- cluster has " << (*pixels).size() << " pixels";
auto pixels = cluster->pixels();
string detectorID = pixels.front()->detectorID();
LOG(DEBUG) << "- cluster has " << pixels.size() << " pixels";
// Loop over all pixels
for(auto& pixel : (*pixels)) {
for(auto& pixel : pixels) {
charge += pixel->charge();
column += (pixel->column() * pixel->charge());
row += (pixel->row() * pixel->charge());
......
......@@ -118,11 +118,11 @@ StatusCode TreeWriterDUT::run(std::shared_ptr<Clipboard> clipboard) {
LOG(DEBUG) << "Gets cluster eventID = " << eventID;
// Get the pixels in the current cluster
Pixels* pixels = cluster->pixels();
auto pixels = cluster->pixels();
// Iterate through all pixels in the cluster
numPixels = 0;
for(auto& pixel : (*pixels)) {
for(auto& pixel : pixels) {
// Increase counter for number of pixels in the cluster
numPixels++;
......
Supports Markdown
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