diff --git a/Event/EventPacker/src/lib/PackedProtoParticle.cpp b/Event/EventPacker/src/lib/PackedProtoParticle.cpp index 12ae60cb7ea252524eb71215caed91739836af22..c5536708e7afed748d603af78a40afda33439837 100644 --- a/Event/EventPacker/src/lib/PackedProtoParticle.cpp +++ b/Event/EventPacker/src/lib/PackedProtoParticle.cpp @@ -174,14 +174,16 @@ StatusCode ProtoParticlePacker::unpack( const PackedData& pproto, Data& proto, c // if the proto is charged-like, unpack CaloChargedPID and BremInfo. If we are in old version without CaloChargedPID // and BremInfo objects, create them from AdditionalInfo if ( -1 != pproto.track ) { - if ( ( ver < 3 ) ) { - auto pid = std::make_unique<Event::Calo::v1::CaloChargedPID>(); - proto.setCaloChargedPID( pid.get() ); - auto binfo = std::make_unique<Event::Calo::v1::BremInfo>(); - proto.setBremInfo( binfo.get() ); + if ( ver < 3 ) { + // only add relevant object if info is there (based on Ecal/Brem acceptance) + bool add_pid = false; + auto pid = std::make_unique<Event::Calo::v1::CaloChargedPID>(); + bool add_binfo = false; + auto binfo = std::make_unique<Event::Calo::v1::BremInfo>(); for ( const auto& [k, v] : with_carry( pprotos.extras(), pproto.firstExtra, pproto.lastExtra ) ) { switch ( k ) { case LHCb::ProtoParticle::InAccEcal: + add_pid = true; pid->setInEcal( StandardPacker::fltPacked( v ) ); break; case LHCb::ProtoParticle::CaloChargedID: @@ -223,6 +225,7 @@ StatusCode ProtoParticlePacker::unpack( const PackedData& pproto, Data& proto, c break; // breminfo case LHCb::ProtoParticle::InAccBrem: + add_binfo = true; binfo->setInBrem( StandardPacker::fltPacked( v ) ); break; case LHCb::ProtoParticle::CaloBremHypoID: @@ -254,8 +257,14 @@ StatusCode ProtoParticlePacker::unpack( const PackedData& pproto, Data& proto, c break; } } - cpids.insert( pid.release() ); - binfos.insert( binfo.release() ); + if ( add_pid ) { + proto.setCaloChargedPID( pid.get() ); + cpids.insert( pid.release() ); + } + if ( add_binfo ) { + proto.setBremInfo( binfo.get() ); + binfos.insert( binfo.release() ); + } } else { if ( -1 != pproto.caloChargedPID ) { if ( StandardPacker::hintAndKey64( pproto.caloChargedPID, &pprotos, &protos, hintID, key ) ) { @@ -358,9 +367,10 @@ StatusCode ProtoParticlePacker::unpack( const PackedData& pproto, Data& proto, c } StatusCode ProtoParticlePacker::unpack( const PackedDataVector& pprotos, DataVector& protos ) const { + const auto ver = pprotos.packingVersion(); protos.reserve( pprotos.data().size() ); parent().debug() << "version " << (int)pprotos.version() << endmsg; - parent().debug() << "packing version " << (int)pprotos.packingVersion() << endmsg; + parent().debug() << "packing version " << ver << endmsg; StatusCode sc = StatusCode::SUCCESS; // create a new container in TES for neutralPIDs, caloChargedPIDs and BremInfo if in an old version @@ -377,25 +387,27 @@ StatusCode ProtoParticlePacker::unpack( const PackedDataVector& pprotos, DataVec } // if a new container in TES for neutralPIDs, caloChargedPIDs and BremInfo was created, put it in TES - if ( ( (int)pprotos.packingVersion() < 2 ) && !npids->empty() ) { + if ( ( ver < 2 ) && !npids->empty() ) { parent() .evtSvc() ->registerObject( "/Event/Rec/NeutralPIDs", npids.release() ) .orThrow( "Error in unpacker putting NeutralPIDs container to TES ", "ProtoParticlePacker" ); } - if ( ( (int)pprotos.packingVersion() < 3 ) && !cpids->empty() && !binfos->empty() ) { + if ( ( ver < 3 ) && !cpids->empty() ) { std::string cpids_address = std::string( fmt::format( - "some/anonymous/location/CaloChargedPIDs/{}", + "/Event/Anonymous/CaloChargedPIDs_{}", std::hash<KeyedContainer<LHCb::Event::Calo::v1::CaloChargedPID, Containers::HashMap>>{}( *cpids ) ) ); parent() .evtSvc() ->registerObject( cpids_address, cpids.release() ) .orThrow( "Error in unpacker putting CaloChargedPIDs container to TES", "ProtoParticlePacker" ); + } + + if ( ( ver < 3 ) && !binfos->empty() ) { std::string binfo_address = std::string( - fmt::format( "some/anonymous/location/BremInfo/{}", + fmt::format( "/Event/Anonymous/BremInfo_{}", std::hash<KeyedContainer<LHCb::Event::Calo::v1::BremInfo, Containers::HashMap>>{}( *binfos ) ) ); - parent() .evtSvc() ->registerObject( binfo_address, binfos.release() ) diff --git a/Event/RecEvent/src/ProtoParticle.cpp b/Event/RecEvent/src/ProtoParticle.cpp index d19f8abd5ac778bd721ca3014780622b5b677255..fb62d82336b5b0b83b47b4129473e28bb1e35fe6 100644 --- a/Event/RecEvent/src/ProtoParticle.cpp +++ b/Event/RecEvent/src/ProtoParticle.cpp @@ -57,8 +57,8 @@ namespace Gaudi::Parsers { std::ostream& LHCb::ProtoParticle::fillStream( std::ostream& s ) const { s << "{" << " Track " << this->track() << " CaloHypos " << this->calo() << " RichPID " << this->richPID() << " MuonPID " - << this->muonPID() << " NeutralPID " << this->neutralPID() << this->caloChargedPID() << " BremInfo " - << this->bremInfo() << " ExtraInfo ["; + << this->muonPID() << " NeutralPID " << this->neutralPID() << " CaloChargedPID " << this->caloChargedPID() + << " BremInfo " << this->bremInfo() << " ExtraInfo ["; for ( const auto& i : extraInfo() ) { const auto info = static_cast<LHCb::ProtoParticle::additionalInfo>( i.first ); s << " " << info << "=" << i.second;