ATLAS Offline Software
Loading...
Searching...
No Matches
xAODL2StandAloneMuonAuxContainerCnv_v1.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
3*/
4
5// $Id: xAODL2StandAloneMuonAuxContainerCnv_v1.cxx 707606 2015-11-12 19:59:49Z krasznaa $
6
7// System include(s):
8#include <stdexcept>
9
10// Gaudi/Athena include(s):
11#include "GaudiKernel/MsgStream.h"
12
13// Core EDM include(s):
15
16// Local include(s):
20
22#define MSGLVL MSG::DEBUG
23
25#define ATH_MSG( MSG ) \
26 do { \
27 if( log.level() <= MSGLVL ) { \
28 log << MSGLVL << MSG << endmsg; \
29 } \
30 } while( 0 )
31
35
36
37namespace {
38
39void migrateVector (const SG::IConstAuxStore& oldObj,
40 SG::IAuxStore& newObj,
41 const char* oldName,
42 const char* newName)
43{
44 size_t sz = oldObj.size();
45 if (!sz) return;
46
48 SG::auxid_t oldId = reg.getAuxID<uint32_t> (oldName);
49 SG::auxid_t newId = reg.getAuxID<float> (newName);
50
51 const uint32_t* oldPtr = reinterpret_cast<const uint32_t*> (oldObj.getData (oldId));
52 float* newPtr = reinterpret_cast<float*> (newObj.getData (newId, sz, sz));
53 if (oldPtr && newPtr) {
54 std::copy (oldPtr, oldPtr+sz, newPtr);
55 }
56}
57
58
59}
60
64 MsgStream& log ) const
65{
66 // Greet the user:
67 ATH_MSG( "Converting xAOD::L2StandAloneMuonAuxContainer_v1 to current version..." );
68
69 // Clear the transient object:
70 newObj->resize( 0 );
71
72 // Copy the payload of the v1 object into the latest one by misusing
73 // the thinning code a bit...
74 SG::copyAuxStoreThinned( *oldObj, *newObj, nullptr );
75
76 size_t sz = oldObj->size();
77 newObj->resize (sz);
78 migrateVector (*oldObj, *newObj, "roiEtaUint", "roiEta");
79 migrateVector (*oldObj, *newObj, "roiPhiUint", "roiPhi");
80
81
82 // Print what happened:
83 ATH_MSG( "Converting xAOD::L2StandAloneMuonAuxContainer_v1 to current version "
84 "[OK]" );
85
86 return;
87}
88
95 MsgStream& log ) const {
96
97 log << MSG::ERROR
98 << "Somebody called xAODL2StandAloneMuonAuxContainer_v1::transToPers"
99 << endmsg;
100 throw std::runtime_error( "Somebody called xAODL2StandAloneMuonAuxContainer_v1::"
101 "transToPers" );
102
103 return;
104}
#define endmsg
#define ATH_MSG(lvl)
static Double_t sz
Handle mappings between names and auxid_t.
static AuxTypeRegistry & instance()
Return the singleton registry instance.
Interface for non-const operations on an auxiliary store.
Definition IAuxStore.h:48
virtual void * getData(auxid_t auxid, size_t size, size_t capacity)=0
Return the data vector for one aux data item.
Interface for const operations on an auxiliary store.
virtual const void * getData(SG::auxid_t auxid) const =0
Return the data vector for one aux data item.
virtual size_t size() const =0
Return the number of elements in the store.
virtual void transToPers(const xAOD::L2StandAloneMuonAuxContainer *, xAOD::L2StandAloneMuonAuxContainer_v1 *, MsgStream &log) const override
Dummy function inherited from the base class.
virtual void persToTrans(const xAOD::L2StandAloneMuonAuxContainer_v1 *oldObj, xAOD::L2StandAloneMuonAuxContainer *newObj, MsgStream &log) const override
Function converting from the old type to the current one.
virtual bool resize(size_t size) override
Resize the arrays to a given size.
virtual size_t size() const override
Get the size of the container.
Auxiliary container for muon SA containers.
Helper to copy an aux store while applying thinning.
void copyAuxStoreThinned(const SG::IConstAuxStore &orig, SG::IAuxStore &copy, const SG::ThinningInfo *info)
Helper to copy an aux store while applying thinning.
size_t auxid_t
Identifier for a particular aux data item.
Definition AuxTypes.h:27
L2StandAloneMuonAuxContainer_v2 L2StandAloneMuonAuxContainer
Define the latest version of the muon SA auxiliary container.