Commit 90323e27 authored by Wouter Deconinck's avatar Wouter Deconinck
Browse files

Avoid illegal narrowing of non-const temporaries in initializer lists

parent e629198f
......@@ -195,22 +195,30 @@ public:
std::transform(cdim.begin(), cdim.end(), cdim.begin(),
std::bind(std::multiplies<double>(), std::placeholders::_1, 2));
}
double dim[3] = {0., 0., 0.};
for (size_t i = 0; i < cdim.size() && i < 3; ++i) {
dim[i] = cdim[i] / m_lUnit;
}
// create const vectors for passing to hit initializer list
const decltype(eicd::CalorimeterHitData::position) position(
gpos.x() / m_lUnit, gpos.y() / m_lUnit, gpos.z() / m_lUnit
);
const decltype(eicd::CalorimeterHitData::dimension) dimension(
cdim[0] / m_lUnit, cdim[1] / m_lUnit, cdim[2] / m_lUnit
);
const decltype(eicd::CalorimeterHitData::local) local(
pos.x() / m_lUnit, pos.y() / m_lUnit, pos.z() / m_lUnit
);
hits.push_back({
rh.getCellID(), // cellID
rh.getCellID(), // cellID
energy, // energy
0, // @TODO: energy error
time, // time
0, // time error FIXME should be configurable
{gpos.x() / m_lUnit, gpos.y() / m_lUnit, gpos.z() / m_lUnit}, // global pos
{dim[0], dim[1], dim[2]},
position, // global pos
dimension,
// Local hit info
sid,
lid,
{pos.x() / m_lUnit, pos.y() / m_lUnit, pos.z() / m_lUnit}, // local pos
local, // local pos
});
}
......
......@@ -149,17 +149,26 @@ public:
timeError = sqrt(timeError) / hits.size();
const auto& href = hits.front();
// create const vectors for passing to hit initializer list
const decltype(eicd::CalorimeterHitData::position) position(
gpos.x() / dd4hep::mm, gpos.y() / dd4hep::mm, gpos.z() / dd4hep::mm
);
const decltype(eicd::CalorimeterHitData::local) local(
pos.x(), pos.y(), pos.z()
);
outputs.push_back(
eicd::CalorimeterHit{ref_id,
energy,
energyError,
time,
timeError,
{gpos.x() / dd4hep::mm, gpos.y() / dd4hep::mm, gpos.z() / dd4hep::mm},
position,
href.getDimension(),
href.getSector(),
href.getLayer(),
{pos.x(), pos.y(), pos.z()}}); // Can do better here? Right now position is mapped on the central hit
local}); // Can do better here? Right now position is mapped on the central hit
}
if (msgLevel(MSG::DEBUG)) {
......
......@@ -63,13 +63,27 @@ static eicd::Vector2f dimScaledLocalDistXY(const CaloHit& h1, const CaloHit& h2)
return {2 * delta.x / dimsum.x, 2 * delta.y / dimsum.y};
}
static eicd::Vector2f globalDistRPhi(const CaloHit& h1, const CaloHit& h2) {
return {eicd::magnitude(h1.getPosition()) - eicd::magnitude(h2.getPosition()),
eicd::angleAzimuthal(h1.getPosition()) - eicd::angleAzimuthal(h2.getPosition())};
using vector_type = decltype(eicd::Vector2f::a);
return {
static_cast<vector_type>(
eicd::magnitude(h1.getPosition()) - eicd::magnitude(h2.getPosition())
),
static_cast<vector_type>(
eicd::angleAzimuthal(h1.getPosition()) - eicd::angleAzimuthal(h2.getPosition())
)
};
}
static eicd::Vector2f globalDistEtaPhi(const CaloHit& h1,
const CaloHit& h2) {
return {eicd::eta(h1.getPosition()) - eicd::eta(h2.getPosition()),
eicd::angleAzimuthal(h1.getPosition()) - eicd::angleAzimuthal(h2.getPosition())};
const CaloHit& h2) {
using vector_type = decltype(eicd::Vector2f::a);
return {
static_cast<vector_type>(
eicd::eta(h1.getPosition()) - eicd::eta(h2.getPosition())
),
static_cast<vector_type>(
eicd::angleAzimuthal(h1.getPosition()) - eicd::angleAzimuthal(h2.getPosition())
)
};
}
// name: {method, units}
static std::map<std::string,
......
......@@ -132,15 +132,24 @@ public:
const auto alignment = volman.lookupDetElement(id).nominal();
const auto pos = alignment.worldToLocal(dd4hep::Position(gpos.x(), gpos.y(), gpos.z()));
hits.push_back(eicd::CalorimeterHit{id, // cellID
static_cast<float>(energy), // energy
0, // energyError
static_cast<float>(time), // time
0, // timeError TODO
{gpos.x() / m_lUnit, gpos.y() / m_lUnit, gpos.z() / m_lUnit}, // global pos
{0, 0, 0}, // @TODO: add dimension
sid,lid,
{pos.x() / m_lUnit, pos.y() / m_lUnit, pos.z() / m_lUnit}}); // local pos
// create const vectors for passing to hit initializer list
const decltype(eicd::CalorimeterHitData::position) position(
gpos.x() / m_lUnit, gpos.y() / m_lUnit, gpos.z() / m_lUnit
);
const decltype(eicd::CalorimeterHitData::local) local(
pos.x() / m_lUnit, pos.y() / m_lUnit, pos.z() / m_lUnit
);
hits.push_back(eicd::CalorimeterHit{id, // cellID
static_cast<float>(energy), // energy
0, // energyError
static_cast<float>(time), // time
0, // timeError TODO
position, // global pos
{0, 0, 0}, // @TODO: add dimension
sid,lid,
local}); // local pos
}
return StatusCode::SUCCESS;
}
......
......@@ -116,6 +116,10 @@ namespace Jug::Reco {
debug() << " chi2 = " << trajState.chi2Sum << endmsg;
}
const eicd::Vector2f loc {
parameter[Acts::eBoundLoc0],
parameter[Acts::eBoundLoc1]
};
const eicd::Cov3f covMomentum {
static_cast<float>(covariance(Acts::eBoundTheta, Acts::eBoundTheta)),
static_cast<float>(covariance(Acts::eBoundPhi, Acts::eBoundPhi)),
......@@ -130,7 +134,7 @@ namespace Jug::Reco {
const float timeError{sqrt(static_cast<float>(covariance(Acts::eBoundTime, Acts::eBoundTime)))};
eicd::TrackParameters pars{0, // type: track head --> 0
{parameter[Acts::eBoundLoc0], parameter[Acts::eBoundLoc1]},
loc,
covPos,
static_cast<float>(parameter[Acts::eBoundTheta]),
static_cast<float>(parameter[Acts::eBoundPhi]),
......@@ -167,8 +171,8 @@ namespace Jug::Reco {
eicd::BasicParticle p{
eicd::sphericalToVector(1.0 / std::abs(params[Acts::eBoundQOverP]),
params[Acts::eBoundTheta],
params[Acts::eBoundPhi]),
params[Acts::eBoundTheta],
params[Acts::eBoundPhi]),
{0., 0., 0.}, // vectex 3-vector
0., // time
0, // PDG particle code
......
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