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

Cluster: add function to retrieve earliest pixel + split getSeedPixel()

parent f839fb60
Pipeline #2680306 passed with stages
in 15 minutes and 33 seconds
......@@ -68,22 +68,31 @@ const Pixel* Cluster::getSeedPixel() const {
seed = pxl;
}
}
} else { // return the earliest pixel:
double earliestTimestamp = std::numeric_limits<double>::max();
for(auto& px : m_pixels) {
auto pxl = dynamic_cast<Pixel*>(px.GetObject());
if(pxl == nullptr) {
throw MissingReferenceException(typeid(*this), typeid(Pixel));
}
return seed;
if(pxl->timestamp() < earliestTimestamp) {
earliestTimestamp = pxl->timestamp();
seed = pxl;
}
} else {
// return the earliest pixel:
return Cluster::getEarliestPixel();
}
}
const Pixel* Cluster::getEarliestPixel() const {
Pixel* earliest = nullptr;
double earliestTimestamp = std::numeric_limits<double>::max();
for(auto& px : m_pixels) {
auto pxl = dynamic_cast<Pixel*>(px.GetObject());
if(pxl == nullptr) {
throw MissingReferenceException(typeid(*this), typeid(Pixel));
}
if(pxl->timestamp() < earliestTimestamp) {
earliestTimestamp = pxl->timestamp();
earliest = pxl;
}
}
return seed;
return earliest;
}
void Cluster::print(std::ostream& out) const {
......
......@@ -73,6 +73,12 @@ namespace corryvreckan {
* @return Seed pixel of the cluster
*/
const Pixel* getSeedPixel() const;
/**
* @brief Retrieve the earliest pixel of the cluster.
*
* @return Earliest pixel of the cluster
*/
const Pixel* getEarliestPixel() const;
// Set cluster parameters
void setColumn(double col) { m_column = col; }
......@@ -108,7 +114,7 @@ namespace corryvreckan {
std::map<int, bool> m_columnHits;
// ROOT I/O class definition - update version number when you change this class!
ClassDefOverride(Cluster, 12)
ClassDefOverride(Cluster, 13)
};
// Vector type declaration
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment