Skip to content
Snippets Groups Projects

loopy unpacking and multi packing

Merged Sevda Esen requested to merge sevda-loopy-unpacking3 into master
All threads resolved!
2 files
+ 1
76
Compare changes
  • Side-by-side
  • Inline
Files
2
/*****************************************************************************\
* (c) Copyright 2000-2018 CERN for the benefit of the LHCb Collaboration *
* *
* This software is distributed under the terms of the GNU General Public *
* Licence version 3 (GPL Version 3), copied verbatim in the file "COPYING". *
* *
* In applying this licence, CERN does not waive the privileges and immunities *
* granted to it by virtue of its status as an Intergovernmental Organization *
* or submit itself to any jurisdiction. *
\*****************************************************************************/
#include "Event/PackedCaloAdc.h"
#include "Event/PackedCaloCluster.h"
#include "Event/PackedCaloDigit.h"
#include "Event/PackedCaloHypo.h"
#include "Event/PackedCluster.h"
#include "Event/PackedData.h"
#include "Event/PackedDataBuffer.h"
#include "Event/PackedFlavourTag.h"
#include "Event/PackedMuonPID.h"
#include "Event/PackedPartToRelatedInfoRelation.h"
#include "Event/PackedParticle.h"
#include "Event/PackedProtoParticle.h"
#include "Event/PackedRecVertex.h"
#include "Event/PackedRelations.h"
#include "Event/PackedRichPID.h"
#include "Event/PackedTrack.h"
#include "Event/PackedVertex.h"
#include "Event/PackedWeightsVector.h"
namespace LHCb::Hlt::PackedData {
/// create map between CLIDs and load functions
template <class PACKER>
std::pair<std::unique_ptr<DataObject>, std::unique_ptr<DataObject>>
loadObject( Gaudi::Algorithm const* algo, PackedDataInBuffer& buffer, std::vector<std::string>& links,
int bytesToRead ) {
auto pdata = std::make_unique<typename PACKER::PackedDataVector>();
auto data = std::make_unique<typename PACKER::DataVector>();
auto nBytesRead = buffer.load( *pdata );
if ( (int)nBytesRead != bytesToRead ) {
// how to pass the counter?
//++m_inconsistentSize;
algo->fatal() << " consumed " << nBytesRead << " bytes, "
<< " but " << bytesToRead << " were stored!" << endmsg;
}
for ( auto link : links ) pdata->linkMgr()->addLink( link, nullptr );
PACKER packer( algo );
data->setVersion( pdata->version() );
packer.unpack( *pdata, *data );
return {std::move( pdata ), std::move( data )};
}
template <class... PACKER>
auto createLoaders() {
std::map<CLID, std::pair<std::unique_ptr<DataObject>, std::unique_ptr<DataObject>> ( * )(
Gaudi::Algorithm const* algo, PackedDataInBuffer& buffer, std::vector<std::string>& links,
int bytesToRead )>
loaders;
( loaders.emplace( PACKER::PackedDataVector::classID(), &loadObject<PACKER> ), ... );
return loaders;
}
const auto loaders =
createLoaders<LHCb::TrackPacker, LHCb::RichPIDPacker, LHCb::MuonPIDPacker, LHCb::CaloHypoPacker,
LHCb::ProtoParticlePacker, LHCb::CaloClusterPacker, LHCb::ParticlePacker, LHCb::VertexPacker,
LHCb::RecVertexPacker, LHCb::FlavourTagPacker, LHCb::CaloDigitPacker, LHCb::CaloAdcPacker>();
} // namespace LHCb::Hlt::PackedData
Loading