diff --git a/Event/EventPacker/include/Event/StandardPacker.h b/Event/EventPacker/include/Event/StandardPacker.h index f98637b0388e1368e143f1d608c57a186624e7fc..115f960640631dcd11c693e2408bd3645e1eedc5 100644 --- a/Event/EventPacker/include/Event/StandardPacker.h +++ b/Event/EventPacker/include/Event/StandardPacker.h @@ -19,6 +19,8 @@ #include "GaudiKernel/LinkManager.h" #include "GaudiKernel/SmartRef.h" +#include "Detector/Calo/CaloCellID.h" + #include <boost/pfr/core.hpp> #include <cmath> @@ -184,6 +186,9 @@ namespace StandardPacker { /** returns an int containing the float representation of the double */ constexpr int fltPacked( double x ) { return bit_cast<int>( static_cast<float>( x ) ); } + /** returns an int containing Calo CellID from bit representation in unsigned int */ + constexpr int caloCellIDPacked( LHCb::Detector::Calo::CellID id ) { return bit_cast<int>( id.all() ); } + /// Returns the 'LinkID' inline std::int64_t linkID( LinkManager& mgr, const DataObject* parent ) { auto* myLink = mgr.link( parent ); @@ -297,4 +302,9 @@ namespace StandardPacker { /** returns an double from a int containing in fact the representation of a float */ constexpr double fltPacked( int k ) { return bit_cast<float>( k ); } + /** returns Calo CellID from an int containing bit representation in unsigned int */ + constexpr LHCb::Detector::Calo::CellID caloCellIDPacked( int k ) { + return LHCb::Detector::Calo::CellID( bit_cast<unsigned>( k ) ); + } + } // namespace StandardPacker diff --git a/Event/EventPacker/src/lib/PackedCaloChargedInfo_v1.cpp b/Event/EventPacker/src/lib/PackedCaloChargedInfo_v1.cpp index 681d23920037c3da263f3eca56f160d347d4abbf..ac33a5139bfb29893df44e4c2b733be6aa8f97a3 100644 --- a/Event/EventPacker/src/lib/PackedCaloChargedInfo_v1.cpp +++ b/Event/EventPacker/src/lib/PackedCaloChargedInfo_v1.cpp @@ -21,9 +21,9 @@ void CaloChargedPIDPacker::pack( const Data& pid, PackedData& ppid, PackedDataVe ppid.key = pid.key(); // save data ppid.InAcc = pid.InEcal() * 0x1 + pid.InHcal() * 0x2; - ppid.ClusterID = pid.ClusterID().all(); + ppid.ClusterID = StandardPacker::caloCellIDPacked( pid.ClusterID() ); ppid.ClusterMatch = StandardPacker::fltPacked( pid.ClusterMatch() ); - ppid.ElectronID = pid.ElectronID().all(); + ppid.ElectronID = StandardPacker::caloCellIDPacked( pid.ElectronID() ); ppid.ElectronMatch = StandardPacker::fltPacked( pid.ElectronMatch() ); ppid.ElectronEnergy = StandardPacker::energy( pid.ElectronEnergy() ); ppid.ElectronShowerEoP = StandardPacker::fltPacked( pid.ElectronShowerEoP() ); @@ -40,9 +40,9 @@ StatusCode CaloChargedPIDPacker::unpack( const PackedData& ppid, Data& pid, cons if ( !isSupportedVer( ver ) ) { return StatusCode::FAILURE; } // unpack the data pid.setInEcal( ppid.InAcc & 0x1 ); - pid.setClusterID( Detector::Calo::CellID( ppid.ClusterID ) ); + pid.setClusterID( StandardPacker::caloCellIDPacked( ppid.ClusterID ) ); pid.setClusterMatch( (float)StandardPacker::fltPacked( ppid.ClusterMatch ) ); - pid.setElectronID( Detector::Calo::CellID( ppid.ElectronID ) ); + pid.setElectronID( StandardPacker::caloCellIDPacked( ppid.ElectronID ) ); pid.setElectronMatch( (float)StandardPacker::fltPacked( ppid.ElectronMatch ) ); pid.setElectronEnergy( (float)StandardPacker::energy( ppid.ElectronEnergy ) ); pid.setElectronShowerEoP( (float)StandardPacker::fltPacked( ppid.ElectronShowerEoP ) ); @@ -116,7 +116,7 @@ void BremInfoPacker::pack( const Data& pid, PackedData& ppid, PackedDataVector& ppid.key = pid.key(); // save data ppid.BremAcc = pid.InBrem() * 0x1 + pid.HasBrem() * 0x2; - ppid.BremHypoID = pid.BremHypoID().all(); + ppid.BremHypoID = StandardPacker::caloCellIDPacked( pid.BremHypoID() ); ppid.BremHypoMatch = StandardPacker::fltPacked( pid.BremHypoMatch() ); ppid.BremHypoEnergy = StandardPacker::energy( pid.BremHypoEnergy() ); ppid.BremHypoDeltaX = StandardPacker::deltaLL( pid.BremHypoDeltaX() ); @@ -131,7 +131,7 @@ StatusCode BremInfoPacker::unpack( const PackedData& ppid, Data& pid, const Pack if ( !isSupportedVer( ver ) ) { return StatusCode::FAILURE; } // unpack the data pid.setInBrem( ppid.BremAcc & 0x1 ); - pid.setBremHypoID( Detector::Calo::CellID( ppid.BremHypoID ) ); + pid.setBremHypoID( Detector::Calo::CellID( bit_cast<unsigned>( ppid.BremHypoID ) ) ); pid.setBremHypoMatch( (float)StandardPacker::fltPacked( ppid.BremHypoMatch ) ); pid.setBremHypoEnergy( (float)StandardPacker::energy( ppid.BremHypoEnergy ) ); pid.setBremHypoDeltaX( (float)StandardPacker::deltaLL( ppid.BremHypoDeltaX ) ); diff --git a/Event/EventPacker/src/lib/PackedNeutralPID.cpp b/Event/EventPacker/src/lib/PackedNeutralPID.cpp index 165ecfa82bfee8cb8ad0467012c311183b463d37..4455c2aec0834f88764c2c52d825221f30c7d733 100644 --- a/Event/EventPacker/src/lib/PackedNeutralPID.cpp +++ b/Event/EventPacker/src/lib/PackedNeutralPID.cpp @@ -20,7 +20,7 @@ void NeutralPIDPacker::pack( const Data& pid, PackedData& ppid, PackedDataVector // save the key ppid.key = pid.key(); // save data - ppid.CaloNeutralID = pid.CaloNeutralID().all(); + ppid.CaloNeutralID = StandardPacker::caloCellIDPacked( pid.CaloNeutralID() ); ppid.ClusterMass = StandardPacker::mass( pid.ClusterMass() ); ppid.CaloNeutralEcal = StandardPacker::energy( pid.CaloNeutralEcal() ); ppid.CaloTrMatch = StandardPacker::fltPacked( pid.CaloTrMatch() ); @@ -39,7 +39,7 @@ StatusCode NeutralPIDPacker::unpack( const PackedData& ppid, Data& pid, const Pa const auto ver = ppids.packingVersion(); if ( !isSupportedVer( ver ) ) { return StatusCode::FAILURE; } // unpack the data - pid.setCaloNeutralID( LHCb::Detector::Calo::CellID( ppid.CaloNeutralID ) ); + pid.setCaloNeutralID( StandardPacker::caloCellIDPacked( ppid.CaloNeutralID ) ); pid.setClusterMass( (float)StandardPacker::mass( ppid.ClusterMass ) ); pid.setCaloNeutralEcal( (float)StandardPacker::energy( ppid.CaloNeutralEcal ) ); pid.setCaloTrMatch( (float)StandardPacker::fltPacked( ppid.CaloTrMatch ) );