Skip to content
Snippets Groups Projects
Commit 8fd863a3 authored by Izaac Sanderswood's avatar Izaac Sanderswood Committed by Miroslav Saur
Browse files

ChargedProtoParticleAddCaloInfo from track ancestor, Give RelationTable1D a...

ChargedProtoParticleAddCaloInfo from track ancestor, Give RelationTable1D a version of add that checks entry is not already added
parent 0676ff36
No related branches found
No related tags found
2 merge requests!4575Synchronize master branch with 2024-patches,!4385ChargedProtoParticleAddCaloInfo from track ancestor, Give RelationTable1D a version of add that checks entry is not already added
......@@ -129,6 +129,21 @@ namespace LHCb::Event {
void add( const typename C1::template proxy_type<simd, behaviour, const C1>& from_proxy, Ts... extras ) {
this->template emplace_back<simd>().set( from_proxy.indices(), extras... );
}
template <SIMDWrapper::InstructionSet simd, LHCb::Pr::ProxyBehaviour behaviour, typename... Ts>
void addUniquely( const typename C1::template proxy_type<simd, behaviour, const C1>& from_proxy, Ts... extras ) {
for ( const auto& existing_entry : this->scalar() ) {
// Check if the existing entry matches the data you want to add
if ( existing_entry.template get<RelationTag::Index1>() == from_proxy.indices() ) {
// Entry with the same index already exists. This function could be updated to consider information in extra
// tags
return; // Skip adding since it already exists
}
}
// If no matching entry is found, add the new entry
this->template emplace_back<simd>().set( from_proxy.indices(), extras... );
}
private:
const C1* m_from;
......
......@@ -112,7 +112,15 @@ namespace LHCb::Rec::ProtoParticle::Charged {
proto->removeCaloHcalInfo();
// find pp with track
if ( !proto->track() ) continue;
auto relation = map.find( proto->track() );
if ( m_useTrackAncestor && !( m_trackAncestorIndex < proto->track()->ancestors().size() ) ) {
throw GaudiException( "Requesting to relate a track ancestor that is not there", "LinkedTo",
StatusCode::FAILURE );
}
auto trackToRelate =
m_useTrackAncestor ? proto->track()->ancestors()[m_trackAncestorIndex].data() : proto->track();
auto relation = map.find( trackToRelate );
if ( map.end() == relation ) {
if ( msgLevel( MSG::VERBOSE ) ) verbose() << " -> NO associated CaloPID object found" << endmsg;
continue;
......@@ -133,6 +141,8 @@ namespace LHCb::Rec::ProtoParticle::Charged {
private:
DataObjectReadHandle<ID2CaloHypoTable> m_calohypotable{this, "ID2CaloHypoTable", "",
"Table relating cellids to CaloHypos"};
Gaudi::Property<bool> m_useTrackAncestor{this, "UseTrackAncestor", false, ""};
Gaudi::Property<unsigned int> m_trackAncestorIndex{this, "TrackAncestorIndex", 0, ""};
};
// Brem info
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment