Commit d6fff055 authored by Chao Peng's avatar Chao Peng Committed by Whitney Armstrong
Browse files

make member functions const

parent d37d422f
......@@ -152,7 +152,7 @@ private:
// helper function for linear interpolation
// Comp return is defined as: equal, 0; greater, > 0; less, < 0
template<class RndmIter, typename T, class Compare>
RndmIter interval_search(RndmIter beg, RndmIter end, const T &val, Compare comp)
RndmIter interval_search(RndmIter beg, RndmIter end, const T &val, Compare comp) const
{
// special cases
auto dist = std::distance(beg, end);
......@@ -178,7 +178,7 @@ private:
return mid;
}
bool qe_pass(double ev, double rand)
bool qe_pass(double ev, double rand) const
{
auto &qeff = u_quantumEfficiency.value();
auto it = interval_search(qeff.begin(), qeff.end(), ev,
......
......@@ -97,7 +97,7 @@ public:
private:
// helper function to group hits
inline bool is_neighbor(const eic::ConstCalorimeterHit &h1, const eic::ConstCalorimeterHit &h2)
inline bool is_neighbor(const eic::ConstCalorimeterHit &h1, const eic::ConstCalorimeterHit &h2) const
{
return (std::abs(h1.local_x() - h2.local_x()) <= (h1.dim_x() + h2.dim_y())/2.*m_groupRange) &&
(std::abs(h1.local_y() - h2.local_y()) <= (h1.dim_y() + h2.dim_y())/2.*m_groupRange);
......@@ -105,7 +105,7 @@ private:
// grouping function with Depth-First Search
void dfs_group(std::vector<eic::CalorimeterHit> &group, int idx,
const eic::CalorimeterHitCollection &hits, std::vector<bool> &visits)
const eic::CalorimeterHitCollection &hits, std::vector<bool> &visits) const
{
auto hit = hits[idx];
group.push_back(hit);
......@@ -120,7 +120,7 @@ private:
}
// find local maxima that above a certain threshold
eic::Cluster find_local_maxima(const std::vector<eic::CalorimeterHit> &group)
eic::Cluster find_local_maxima(const std::vector<eic::CalorimeterHit> &group) const
{
eic::Cluster maxima;
for(auto &hit : group)
......@@ -151,7 +151,7 @@ private:
}
// helper function
inline void vec_normalize(std::vector<double> &vals) {
inline void vec_normalize(std::vector<double> &vals) const {
double total = 0.;
for (auto &val : vals) { total += val; }
for (auto &val : vals) { val /= total; }
......@@ -160,7 +160,7 @@ private:
// split a group of hits according to the local maxima
// split_hits is used to persistify the data
void split_group(const std::vector<eic::CalorimeterHit> &group, const eic::Cluster &maxima,
eic::ClusterCollection &clusters, eic::CalorimeterHitCollection &split_hits)
eic::ClusterCollection &clusters, eic::CalorimeterHitCollection &split_hits) const
{
// special cases
if (maxima.hits_size() == 0) {
......
......@@ -71,8 +71,10 @@ public:
// input collections
auto &clusters = *m_clusterCollection.get();
// reconstruct hit position for the cluster
for (auto &cl : clusters) {
reconstruct(cl);
for (auto cl : clusters) {
auto hit = reconstruct(cl);
cl.energy(hit.energy());
cl.position(hit.position());
// info() << cl.energy()/GeV << " GeV, (" << cl.position().x/mm << ", "
// << cl.position().y/mm << ", " << cl.position().z/mm << ")" << endmsg;
}
......@@ -81,11 +83,12 @@ public:
}
private:
void reconstruct(eic::Cluster cl)
eic::CalorimeterHit reconstruct(eic::Cluster cl) const
{
eic::CalorimeterHit res;
// no hits
if (cl.hits_size() == 0) {
return;
return res;;
}
// calculate total energy, find the cell with the maximum energy deposit
......@@ -99,7 +102,8 @@ private:
centerID = hit.cellID();
}
}
cl.energy(totalE);
res.cellID(centerID);
res.energy(totalE);
// center of gravity with logarithmic weighting
float tw = 0., x = 0., y = 0., z = 0.;
......@@ -111,13 +115,15 @@ private:
y += hit.local_y() * w;
z += hit.local_z() * w;
}
res.local({x/tw, y/tw, z/tw + m_depthCorrection});
// convert local position to global position, use the cell with max edep as a reference
auto volman = m_geoSvc->detector()->volumeManager();
auto alignment = volman.lookupDetector(centerID).nominal();
auto gpos = alignment.localToWorld(dd4hep::Position(x/tw, y/tw, z/tw + m_depthCorrection));
auto gpos = alignment.localToWorld(dd4hep::Position(res.local_x(), res.local_y(), res.local_z()));
cl.position({gpos.x(), gpos.y(), gpos.z()});
res.position({gpos.x(), gpos.y(), gpos.z()});
return res;
}
};
......
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