Commit a263fd56 authored by Jens Kroeger's avatar Jens Kroeger
Browse files

Merge branch 'col_row' into 'master'

Swap column/row in Detector::getLocalPosition to be consistent

See merge request corryvreckan/corryvreckan!96
parents 4a6478cf 49268cab
Pipeline #842696 passed with stages
in 14 minutes and 53 seconds
......@@ -322,7 +322,7 @@ double Detector::getColumn(const PositionVector3D<Cartesian3D<double>> localPosi
}
// Function to get local position from row and column
PositionVector3D<Cartesian3D<double>> Detector::getLocalPosition(double row, double column) const {
PositionVector3D<Cartesian3D<double>> Detector::getLocalPosition(double column, double row) const {
return PositionVector3D<Cartesian3D<double>>(
m_pitch.X() * (column - m_nPixels.X() / 2.), m_pitch.Y() * (row - m_nPixels.Y() / 2.), 0.);
......
......@@ -203,8 +203,8 @@ namespace corryvreckan {
double getRow(PositionVector3D<Cartesian3D<double>> localPosition) const;
double getColumn(PositionVector3D<Cartesian3D<double>> localPosition) const;
// Function to get local position from row and column
PositionVector3D<Cartesian3D<double>> getLocalPosition(double row, double column) const;
// Function to get local position from column (x) and row (y) coordinates
PositionVector3D<Cartesian3D<double>> getLocalPosition(double column, double row) const;
/**
* Transformation from local (sensor) coordinates to in-pixel coordinates
......
......@@ -409,7 +409,7 @@ StatusCode AnalysisCLICpix::run(std::shared_ptr<Clipboard> clipboard) {
// Get the pixel global position
LOG(TRACE) <<"New pixel, row = "<<(*itPixel)->row()<<", column = "<<(*itPixel)->column();
PositionVector3D<Cartesian3D<double> > pixelPositionLocal =
m_detector->getLocalPosition((*itPixel)->row(),(*itPixel)->column()); PositionVector3D<Cartesian3D<double> >
m_detector->getLocalPosition((*itPixel)->column(),(*itPixel)->row()); PositionVector3D<Cartesian3D<double> >
pixelPositionGlobal = *(m_detector->m_localToGlobal) * pixelPositionLocal;
// Check if it is close to the track
......@@ -586,7 +586,7 @@ void AnalysisCLICpix::fillResponseHistos(double trackInterceptX, double trackInt
Pixel* pixel = (*itp);
// Get the pixel local then global position
PositionVector3D<Cartesian3D<double>> pixelPositionLocal =
m_detector->getLocalPosition(pixel->row(), pixel->column());
m_detector->getLocalPosition(pixel->column(), pixel->row());
PositionVector3D<Cartesian3D<double>> pixelPositionGlobal = m_detector->localToGlobal(pixelPositionLocal);
// Fill the response histograms
......
......@@ -72,7 +72,7 @@ StatusCode Clustering4D::run(std::shared_ptr<Clipboard> clipboard) {
cluster->addPixel(pixel);
double clusterTime = pixel->timestamp();
used[pixel] = true;
LOG(DEBUG) << "Adding pixel: " << pixel->row() << "," << pixel->column();
LOG(DEBUG) << "Adding pixel: " << pixel->column() << "," << pixel->row();
size_t nPixels = 0;
while(cluster->size() != nPixels) {
......@@ -99,7 +99,7 @@ StatusCode Clustering4D::run(std::shared_ptr<Clipboard> clipboard) {
cluster->addPixel(neighbour);
clusterTime = neighbour->timestamp();
used[neighbour] = true;
LOG(DEBUG) << "Adding pixel: " << neighbour->row() << "," << neighbour->column() << " time "
LOG(DEBUG) << "Adding pixel: " << neighbour->column() << "," << neighbour->row() << " time "
<< Units::display(neighbour->timestamp(), {"ns", "us", "s"});
}
}
......
......@@ -70,7 +70,7 @@ StatusCode ClusteringSpatial::run(std::shared_ptr<Clipboard> clipboard) {
// Pre-fill the hitmap with pixels
for(auto pixel : (*pixels)) {
hitmap[pixel->row()][pixel->column()] = pixel;
hitmap[pixel->column()][pixel->row()] = pixel;
}
for(auto pixel : (*pixels)) {
......@@ -104,18 +104,18 @@ StatusCode ClusteringSpatial::run(std::shared_ptr<Clipboard> clipboard) {
}
// If no pixel in this position, or is already in a cluster, do nothing
if(!hitmap[row][col]) {
if(!hitmap[col][row]) {
continue;
}
if(used[hitmap[row][col]]) {
if(used[hitmap[col][row]]) {
continue;
}
// Otherwise add the pixel to the cluster and store it as a found
// neighbour
cluster->addPixel(hitmap[row][col]);
used[hitmap[row][col]] = true;
neighbours.push_back(hitmap[row][col]);
cluster->addPixel(hitmap[col][row]);
used[hitmap[col][row]] = true;
neighbours.push_back(hitmap[col][row]);
}
}
......@@ -170,14 +170,14 @@ void ClusteringSpatial::calculateClusterCentre(Cluster* cluster) {
tot += pixel->adc();
row += (pixel->row() * pixel->adc());
column += (pixel->column() * pixel->adc());
LOG(DEBUG) << "- pixel row, col: " << pixel->row() << "," << pixel->column();
LOG(DEBUG) << "- pixel col, row: " << pixel->column() << "," << pixel->row();
}
// Row and column positions are tot-weighted
row /= (tot > 0 ? tot : 1);
column /= (tot > 0 ? tot : 1);
LOG(DEBUG) << "- cluster row, col: " << row << "," << column;
LOG(DEBUG) << "- cluster col, row: " << column << "," << row;
// Create object with local cluster position
PositionVector3D<Cartesian3D<double>> positionLocal(m_detector->pitch().X() * (column - m_detector->nPixels().X() / 2.),
......
......@@ -321,7 +321,7 @@ Pixels* EventLoaderATLASpix::read_caribou_data(double start_time, double end_tim
<< "\tTS_FULL: " << hit_ts << "\t" << Units::display(timestamp, {"s", "us", "ns"})
<< "\tTOT: " << tot; // << "\t" << Units::display(tot_ns, {"s", "us", "ns"});
Pixel* pixel = new Pixel(m_detector->name(), row, col, tot, timestamp);
Pixel* pixel = new Pixel(m_detector->name(), col, row, tot, timestamp);
LOG(DEBUG) << "PIXEL:\t" << *pixel;
pixels->push_back(pixel);
......@@ -532,7 +532,7 @@ Pixels* EventLoaderATLASpix::read_legacy_data(double, double) {
// Convert TOA to nanoseconds:
toa_timestamp /= (4096. * 0.04);
Pixel* pixel = new Pixel(m_detector->name(), row, col, tot, toa_timestamp);
Pixel* pixel = new Pixel(m_detector->name(), col, row, tot, toa_timestamp);
pixel->setCharge(cal_tot);
pixels->push_back(pixel);
}
......
......@@ -107,7 +107,7 @@ StatusCode EventLoaderCLICpix::run(std::shared_ptr<Clipboard> clipboard) {
// If this pixel is masked, do not save it
if(m_detector->masked(col, row))
continue;
Pixel* pixel = new Pixel(m_detector->name(), row, col, tot, 0);
Pixel* pixel = new Pixel(m_detector->name(), col, row, tot, 0);
pixels->push_back(pixel);
npixels++;
hHitMap->Fill(col, row);
......
......@@ -275,7 +275,7 @@ StatusCode EventLoaderCLICpix2::run(std::shared_ptr<Clipboard> clipboard) {
}
}
Pixel* pixel = new Pixel(m_detector->name(), row, col, tot, timestamp);
Pixel* pixel = new Pixel(m_detector->name(), col, row, tot, timestamp);
if(tot == 0 && discardZeroToT) {
hHitMapDiscarded->Fill(col, row);
......
......@@ -76,7 +76,7 @@ StatusCode EventLoaderEUDAQ::run(std::shared_ptr<Clipboard> clipboard) {
continue;
}
Pixel* pixel = new Pixel(detectorID, row, col, static_cast<int>(plane.GetPixel(ipix)));
Pixel* pixel = new Pixel(detectorID, col, row, static_cast<int>(plane.GetPixel(ipix)));
pixel->setCharge(plane.GetPixel(ipix));
// Pixel gets timestamp of trigger assigned:
......
......@@ -147,7 +147,7 @@ void EventLoaderEUDAQ2::store_data(std::shared_ptr<Clipboard> clipboard, std::sh
}
Pixel* pixel =
new Pixel(m_detector->name(), row, col, static_cast<int>(plane.GetPixel(i)), plane.GetTimestamp(i));
new Pixel(m_detector->name(), col, row, static_cast<int>(plane.GetPixel(i)), plane.GetTimestamp(i));
pixels->push_back(pixel);
}
}
......
......@@ -84,7 +84,7 @@ StatusCode EventLoaderMuPixTelescope::run(std::shared_ptr<Clipboard> clipboard)
RawHit h = tf.get_hit(i);
if(h.tag() == 0x4)
h = tf.get_hit(i, 66);
Pixel* p = new Pixel(detectors.at(h.tag() / 4), h.row(), h.column(), 1, 0, true);
Pixel* p = new Pixel(detectors.at(h.tag() / 4), h.column(), h.row(), 1, 0, true);
p->setTimestamp(8 * static_cast<double>(((tf.timestamp() >> 2) & 0xFFFFF700) + h.timestamp_raw()));
p->setToT(0);
......
......@@ -157,7 +157,7 @@ StatusCode EventLoaderTimepix1::run(std::shared_ptr<Clipboard> clipboard) {
// load the real event data, and make a new pixel object
istringstream detectorData(data);
detectorData >> col >> row >> tot;
Pixel* pixel = new Pixel(m_currentDevice, row, col, tot);
Pixel* pixel = new Pixel(m_currentDevice, col, row, tot);
// FIXME to work properly, m_eventTime needs to be converted to nanoseconds!
pixel->timestamp(static_cast<double>(m_eventTime));
dataContainers[m_currentDevice]->push_back(pixel);
......
......@@ -613,7 +613,7 @@ bool EventLoaderTimepix3::loadData(std::shared_ptr<Clipboard> clipboard, Pixels*
LOG(DEBUG) << "Time shift= " << Units::display(t_shift, {"s", "ns"});
LOG(DEBUG) << "Timestamp calibrated = " << Units::display(ftimestamp, {"s", "ns"});
// creating new pixel object with calibrated values of tot and toa
Pixel* pixel = new Pixel(detectorID, row, col, static_cast<int>(tot), ftimestamp);
Pixel* pixel = new Pixel(detectorID, col, row, static_cast<int>(tot), ftimestamp);
pixel->setCharge(fcharge);
devicedata->push_back(pixel);
hHitMap->Fill(col, row);
......@@ -622,7 +622,7 @@ bool EventLoaderTimepix3::loadData(std::shared_ptr<Clipboard> clipboard, Pixels*
} else {
LOG(DEBUG) << "Pixel hit at " << Units::display(timestamp, {"s", "ns"});
// creating new pixel object with non-calibrated values of tot and toa
Pixel* pixel = new Pixel(detectorID, row, col, static_cast<int>(tot), timestamp);
Pixel* pixel = new Pixel(detectorID, col, row, static_cast<int>(tot), timestamp);
devicedata->push_back(pixel);
hHitMap->Fill(col, row);
}
......
......@@ -13,10 +13,10 @@ namespace corryvreckan {
public:
// Constructors and destructors
Pixel() = default;
Pixel(std::string detectorID, int row, int col, int tot) : Pixel(detectorID, row, col, tot, 0.) {}
Pixel(std::string detectorID, int row, int col, int tot, double timestamp)
: Pixel(detectorID, row, col, tot, timestamp, false) {}
Pixel(std::string detectorID, int row, int col, int tot, double timestamp, bool binary)
Pixel(std::string detectorID, int col, int row, int tot) : Pixel(detectorID, col, row, tot, 0.) {}
Pixel(std::string detectorID, int col, int row, int tot, double timestamp)
: Pixel(detectorID, col, row, tot, timestamp, false) {}
Pixel(std::string detectorID, int col, int row, int tot, double timestamp, bool binary)
: Object(detectorID, timestamp), m_row(row), m_column(col), m_adc(tot), m_charge(tot), m_isBinary(binary) {}
int row() const { return m_row; }
......@@ -40,7 +40,7 @@ namespace corryvreckan {
/**
* @brief ROOT class definition
*/
ClassDefOverride(Pixel, 5);
ClassDefOverride(Pixel, 6);
private:
// Member variables
......
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