Closed gordonwatts closed 4 months ago
The following query generates incorrect C++ code:
pv_query = ( ds .Select(lambda e: e.Vertices("PrimaryVertices")) .Select(lambda vtx: vtx.First()) ) track_query = ( pv_query .Select(lambda v: v.trackParticleLinks().Where(lambda t: t.pt() > 500.0)) .Select(lambda tracks: { "pt": tracks.Select(lambda t: t.pt()), "eta": tracks.Select(lambda t: t.eta()), "phi": tracks.Select(lambda t: t.phi()), }) ) tracks= track_query.AsAwkwardArray().value()
The C++ code generated:
{ { const DataVector<xAOD::Vertex_v1>* vertices13; bool is_first15 (true); { const DataVector<xAOD::Vertex_v1>* result = 0; ANA_CHECK (evtStore()->retrieve(result, "PrimaryVertices")); vertices13 = result; } for (auto &&i_obj14 : *vertices13) { if (is_first15) { is_first15 = false; for (auto &&i_obj16 : i_obj14->trackParticleLinks()) { if (((*i_obj16)->pt()>500.0)) { _pt19.push_back((*i_obj16)->pt()); } } } } for (auto &&i_obj17 : i_obj14->trackParticleLinks()) { if (((*i_obj17)->pt()>500.0)) { _eta20.push_back((*i_obj17)->eta()); } } for (auto &&i_obj18 : i_obj14->trackParticleLinks()) { if (((*i_obj18)->pt()>500.0)) { _phi21.push_back((*i_obj18)->phi()); } } tree("atlas_xaod_tree")->Fill(); _pt19.clear(); _eta20.clear(); _phi21.clear(); } return StatusCode::SUCCESS; }
Note the second (and further) i_obj14->trackParticleLinks() are outside the generated First C++ - and so i_obj14 is no longer valid.
i_obj14->trackParticleLinks()
First
i_obj14
The following query generates incorrect C++ code:
The C++ code generated:
Note the second (and further)
i_obj14->trackParticleLinks()
are outside the generatedFirst
C++ - and soi_obj14
is no longer valid.