ATLAS Offline Software
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 
33 {
34 }
35 
36 
37 namespace {
38 
39 void 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 }
SG::copyAuxStoreThinned
void copyAuxStoreThinned(const SG::IConstAuxStore &orig, SG::IAuxStore &copy, const SG::ThinningInfo *info)
Helper to copy an aux store while applying thinning.
SG::IConstAuxStore::getData
virtual const void * getData(SG::auxid_t auxid) const =0
Return the data vector for one aux data item.
fitman.sz
sz
Definition: fitman.py:527
SG::AuxTypeRegistry::instance
static AuxTypeRegistry & instance()
Return the singleton registry instance.
Definition: AuxTypeRegistry.cxx:639
xAOD::uint32_t
setEventNumber uint32_t
Definition: EventInfo_v1.cxx:127
ATH_MSG
#define ATH_MSG(MSG)
Another convenience macro for printing messages in the converter.
Definition: xAODL2StandAloneMuonAuxContainerCnv_v1.cxx:25
xAODL2StandAloneMuonAuxContainerCnv_v1.h
L2StandAloneMuonAuxContainer_v1.h
xAOD::AuxContainerBase::resize
virtual bool resize(size_t size) override
Resize the arrays to a given size.
Definition: AuxContainerBase.cxx:505
SG::IConstAuxStore::size
virtual size_t size() const =0
Return the number of elements in the store.
xAODL2StandAloneMuonAuxContainerCnv_v1::transToPers
virtual void transToPers(const xAOD::L2StandAloneMuonAuxContainer *, xAOD::L2StandAloneMuonAuxContainer_v1 *, MsgStream &log) const override
Dummy function inherited from the base class.
Definition: xAODL2StandAloneMuonAuxContainerCnv_v1.cxx:93
xAOD::L2StandAloneMuonAuxContainer_v1
Auxiliary container for muon SA containers.
Definition: L2StandAloneMuonAuxContainer_v1.h:32
SG::AuxTypeRegistry
Handle mappings between names and auxid_t.
Definition: AuxTypeRegistry.h:61
xAOD::AuxContainerBase::size
virtual size_t size() const override
Get the size of the container.
Definition: AuxContainerBase.cxx:430
SG::auxid_t
size_t auxid_t
Identifier for a particular aux data item.
Definition: AuxTypes.h:27
copyAuxStoreThinned.h
Helper to copy an aux store while applying thinning.
endmsg
#define endmsg
Definition: AnalysisConfig_Ntuple.cxx:63
xAODL2StandAloneMuonAuxContainerCnv_v1::xAODL2StandAloneMuonAuxContainerCnv_v1
xAODL2StandAloneMuonAuxContainerCnv_v1()
Default constructor.
Definition: xAODL2StandAloneMuonAuxContainerCnv_v1.cxx:32
xAOD::L2StandAloneMuonAuxContainer_v2
Auxiliary container for muon SA containers.
Definition: L2StandAloneMuonAuxContainer_v2.h:32
MakeNewFileFromOldAndSubstitution.newName
dictionary newName
Definition: ICHEP2016/MakeNewFileFromOldAndSubstitution.py:95
SG::IAuxStore
Interface for non-const operations on an auxiliary store.
Definition: IAuxStore.h:48
SG::IAuxStore::getData
virtual void * getData(auxid_t auxid, size_t size, size_t capacity)=0
Return the data vector for one aux data item.
xAODL2StandAloneMuonAuxContainerCnv_v1::persToTrans
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.
Definition: xAODL2StandAloneMuonAuxContainerCnv_v1.cxx:62
python.CaloCondTools.log
log
Definition: CaloCondTools.py:20
calibdata.copy
bool copy
Definition: calibdata.py:27
SG::IConstAuxStore
Interface for const operations on an auxiliary store.
Definition: IConstAuxStore.h:64
SG::AuxTypeRegistry::getAuxID
SG::auxid_t getAuxID(const std::string &name, const std::string &clsname="", const Flags flags=Flags::None, const SG::auxid_t linkedVariable=SG::null_auxid)
Look up a name -> auxid_t mapping.
L2StandAloneMuonAuxContainer.h