Skip to content
Snippets Groups Projects

increase version number of PackedTrack to reflect change in the definition of LHCbID

Merged Gerhard Raven requested to merge bump-packed-track-version into master
1 file
+ 44
18
Compare changes
  • Side-by-side
  • Inline
@@ -16,9 +16,21 @@ using namespace LHCb;
void TrackPacker::pack( const Data& track, PackedData& ptrack, PackedDataVector& ptracks ) const {
// check version
const auto ver = ptracks.packingVersion();
if ( !isSupportedVer( ver ) ) return;
// check versions
const auto pver = ptracks.packingVersion();
if ( !isSupportedVer( pver ) ) { return; }
// work around for the fact in old data there was no explicit packing version and
// the DataObject version of the packed container was (ab)used for this.
// To handle this for the old DataObject based event model and packing ensure
// the two values are synchronised...
// This should not be done when we migrate to the packing for the new event model where
// DataObject should not be used anywhere...
ptracks.setVersion( pver );
if ( parent().msgLevel( MSG::DEBUG ) ) {
parent().debug() << "pack : PackingVer=" << (int)pver << " DataVer=" << (int)ptracks.version() << endmsg;
}
ptrack.chi2PerDoF = StandardPacker::fltPacked( track.chi2PerDoF() );
ptrack.nDoF = track.nDoF();
@@ -49,9 +61,10 @@ void TrackPacker::pack( const Data& track, PackedData& ptrack, PackedDataVector&
}
void TrackPacker::pack( const DataVector& tracks, PackedDataVector& ptracks ) const {
// check version
const auto ver = ptracks.packingVersion();
if ( !isSupportedVer( ver ) ) return;
const auto pver = ptracks.packingVersion();
if ( !isSupportedVer( pver ) ) { return; }
// pack
ptracks.data().reserve( tracks.size() );
for ( const auto* track : tracks ) {
@@ -107,9 +120,21 @@ void TrackPacker::convertState( const LHCb::State& state, PackedDataVector& ptra
void TrackPacker::unpack( const PackedData& ptrack, Data& track, const PackedDataVector& ptracks,
DataVector& /* tracks */ ) const {
// Check version
const auto ver = ptracks.packingVersion();
if ( !isSupportedVer( ver ) ) return;
// Check versions
auto pver = ptracks.packingVersion();
if ( !isSupportedVer( pver ) ) { return; }
if ( parent().msgLevel( MSG::DEBUG ) ) {
parent().debug() << "unpack : PackingVer=" << (int)pver << " DataVer=" << (int)ptracks.version() << endmsg;
}
// Work around for old data that (ab)used the DataObject version for the packing version and
// does not have an explicit packingVersion saved in the data. In this case the ROOT schema
// evolution simply fills this member with the default value, which is defaultPackingVersion().
// We attempt to detect this here and correct the packing version to the older value.
// This is only needed as long as we need support for older DataObject based persistency.
const auto ver = ptracks.version();
if ( pver == PackedTracks::defaultPackingVersion() && pver > ver ) { pver = ver; }
// Try and detect changes that require the cached wrap IDs to be reset.
// trigger a reset if a new packed container is detected, or if the
@@ -123,7 +148,7 @@ void TrackPacker::unpack( const PackedData& ptrack, Data& track, const PackedDat
track.setChi2PerDoF( StandardPacker::fltPacked( ptrack.chi2PerDoF ) );
track.setNDoF( ptrack.nDoF );
track.setFlags( ptrack.flags );
if ( ver > 2 ) {
if ( pver > 2 ) {
track.setLikelihood( StandardPacker::fltPacked( ptrack.likelihood ) );
track.setGhostProbability( StandardPacker::fltPacked( ptrack.ghostProba ) );
}
@@ -133,7 +158,7 @@ void TrackPacker::unpack( const PackedData& ptrack, Data& track, const PackedDat
int lastId = ptrack.lastId;
// Apply protection for short int wrapping
if ( ver < 5 && ptracks.ids().size() > std::numeric_limits<uint8_t>::max() ) {
if ( pver < 5 && ptracks.ids().size() > std::numeric_limits<uint8_t>::max() ) {
firstId = m_firstIdHigh + ptrack.firstId;
lastId = m_lastIdHigh + ptrack.lastId;
if ( lastId < firstId ) { // we wrapped in the track
@@ -154,9 +179,9 @@ void TrackPacker::unpack( const PackedData& ptrack, Data& track, const PackedDat
std::vector<LHCb::LHCbID> lhcbids;
lhcbids.reserve( lastId - firstId );
std::transform( std::next( ptracks.ids().begin(), firstId ), std::next( ptracks.ids().begin(), lastId ),
std::back_inserter( lhcbids ), [&ver]( const auto i ) {
std::back_inserter( lhcbids ), [&pver]( const auto i ) {
LHCb::LHCbID id( i );
if ( ver < 6 ) {
if ( pver < 6 ) {
// Fixup channelIDtype for old (<6) data
// Adapts to https://gitlab.cern.ch/lhcb/LHCb/-/merge_requests/3226
enum class OLD_channelIDtype { Velo = 1, TT, IT, OT, Rich, Calo, Muon, VP, FT = 10, UT, HC };
@@ -181,7 +206,7 @@ void TrackPacker::unpack( const PackedData& ptrack, Data& track, const PackedDat
return id;
} );
// schema change: sorting no longer needed when we write DSTs with sorted lhcbids
if ( ver <= 1 ) { std::sort( lhcbids.begin(), lhcbids.end() ); }
if ( pver <= 1 ) { std::sort( lhcbids.begin(), lhcbids.end() ); }
track.addSortedToLhcbIDs( lhcbids );
// extract the first and last indices for the states for this track
@@ -189,7 +214,7 @@ void TrackPacker::unpack( const PackedData& ptrack, Data& track, const PackedDat
int lastState = ptrack.lastState;
// protection for short int wrapping
if ( ver < 5 && ptracks.states().size() > std::numeric_limits<uint8_t>::max() ) {
if ( pver < 5 && ptracks.states().size() > std::numeric_limits<uint8_t>::max() ) {
firstState = m_firstStateHigh + ptrack.firstState;
lastState = m_lastStateHigh + ptrack.lastState;
if ( lastState < firstState ) { // we wrapped in the track
@@ -216,7 +241,7 @@ void TrackPacker::unpack( const PackedData& ptrack, Data& track, const PackedDat
int lastExtra = ptrack.lastExtra;
// protect against short int wrapping
if ( ver < 5 && ptracks.extras().size() > std::numeric_limits<uint8_t>::max() ) {
if ( pver < 5 && ptracks.extras().size() > std::numeric_limits<uint8_t>::max() ) {
firstExtra = m_firstExtraHigh + ptrack.firstExtra;
lastExtra = m_lastExtraHigh + ptrack.lastExtra;
if ( lastExtra < firstExtra ) { // we wrapped in the track
@@ -241,7 +266,7 @@ void TrackPacker::unpack( const PackedData& ptrack, Data& track, const PackedDat
} );
//== Cleanup extraInfo and set likelihood/ghostProbability for old data
if ( ver <= 2 ) {
if ( pver <= 2 ) {
track.eraseInfo( LHCb::Track::AdditionalInfo::PatQuality );
track.eraseInfo( LHCb::Track::AdditionalInfo::Cand1stQPat );
track.eraseInfo( LHCb::Track::AdditionalInfo::Cand2ndQPat );
@@ -256,9 +281,10 @@ void TrackPacker::unpack( const PackedData& ptrack, Data& track, const PackedDat
}
void TrackPacker::unpack( const PackedDataVector& ptracks, DataVector& tracks ) const {
// Check version
const auto ver = ptracks.packingVersion();
if ( !isSupportedVer( ver ) ) return;
const auto pver = ptracks.packingVersion();
if ( !isSupportedVer( pver ) ) { return; }
// reserve the required size
tracks.reserve( ptracks.data().size() );
Loading