ATLAS Offline Software
Loading...
Searching...
No Matches
xAODRODHeaderAuxContainerCnv_v1.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3*/
4
5
6// System include(s):
7#include <stdexcept>
8#include <array>
9
10// Gaudi/Athena include(s):
11#include "GaudiKernel/MsgStream.h"
12
13// EDM include(s):
17
18// 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
39 MsgStream& log ) const {
40
41 // Greet the user:
42 ATH_MSG( "Converting xAOD::RODHeaderAuxContainer_v1 to current "
43 "version..." );
44
45 // Clear the transient object:
46 newObj->resize( 0 );
47
48 // Set up interface containers on top of the auxiliary ones:
50 for( size_t i = 0; i < oldObj->size(); ++i ) {
51 oldInt.push_back( new xAOD::RODHeader_v1() );
52 }
53 oldInt.setStore( oldObj );
55 newInt.setStore( newObj );
56
57 // Loop over the interface objects, and do the conversion with their help:
58 for( const xAOD::RODHeader_v1* oldRH : oldInt ) {
59
60 // Create an object for the new container:
61 xAOD::RODHeader* newRH = new xAOD::RODHeader();
62 newInt.push_back( newRH );
63
64 // Copy all the variables that the interface knows about:
65 newRH->initialize( oldRH->version(), oldRH->sourceId(), oldRH->run(),
66 oldRH->lvl1Id(), oldRH->bcid(), oldRH->trigType(),
67 oldRH->detType(), oldRH->statusWords(),
68 oldRH->payloadSize() );
69
70 // Helper objects to access the auxiliary IDs of the base variables:
71 static const SG::AuxElement::TypelessConstAccessor accVersion( "version" );
72 static const SG::AuxElement::TypelessConstAccessor accSourceId( "sourceId" );
73 static const SG::AuxElement::TypelessConstAccessor accRun( "run" );
74 static const SG::AuxElement::TypelessConstAccessor accLvl1Id( "lvl1Id" );
75 static const SG::AuxElement::TypelessConstAccessor accBcid( "bcId" );
76 static const SG::AuxElement::TypelessConstAccessor accTrigType( "trigType" );
77 static const SG::AuxElement::TypelessConstAccessor accDetType( "detType" );
79 accStatusWords( "statusWords" );
81 accPayloadSize( "payloadSize" );
82 static const std::array< const SG::AuxElement::TypelessConstAccessor*, 9 >
83 knownVars{ { &accVersion, &accSourceId, &accRun, &accLvl1Id, &accBcid,
84 &accTrigType, &accDetType, &accStatusWords, &accPayloadSize } };
85
86 // The index of the objects in their respective containers:
87 const size_t oindex = oldRH->index();
88 const size_t nindex = newRH->index();
89
90 // The auxiliary registry, used in the copying:
92
93 // Now copy over all the dynamic variables, which were not covered
94 // by the previous lines:
95 for( SG::auxid_t auxid : oldObj->getAuxIDs() ) {
96
97 // Ignore the ones that we already copied:
98 bool ignore = false;
99 for( const auto * acc : knownVars ) {
100 if( auxid == acc->auxid() ) {
101 ignore = true;
102 break;
103 }
104 }
105 if( ignore ) {
106 continue;
107 }
108
109 // Copy the variable:
110 r.copy( auxid, newInt, nindex, oldInt, oindex, 1 );
111 }
112 }
113
114 // Tell the user what happened:
115 ATH_MSG( "Converting xAOD::RODHeaderAuxContainer_v1 to current version "
116 "[OK]" );
117
118 // Return gracefully:
119 return;
120}
121
126 MsgStream& log ) const {
127
128 log << MSG::ERROR << "xAODRODHeaderAuxContainerCnv_v1::transToPers got "
129 << "called" << endmsg;
130 throw std::runtime_error( "xAODRODHeaderAuxContainerCnv_v1::transToPers "
131 "got called" );
132
133 return;
134}
#define endmsg
#define ATH_MSG(lvl)
Handle mappings between names and auxid_t.
value_type push_back(value_type pElem)
Add an element to the end of the collection.
ConstAuxElement::TypelessConstAccessor TypelessConstAccessor
Definition AuxElement.h:566
size_t index() const
Return the index of this element within its container.
Handle mappings between names and auxid_t.
static AuxTypeRegistry & instance()
Return the singleton registry instance.
virtual void persToTrans(const xAOD::RODHeaderAuxContainer_v1 *oldObj, xAOD::RODHeaderAuxContainer *newObj, MsgStream &log) const override
Function converting from the old type to the current one.
virtual void transToPers(const xAOD::RODHeaderAuxContainer *, xAOD::RODHeaderAuxContainer_v1 *, MsgStream &log) const override
Dummy function inherited from the base class.
virtual bool resize(size_t size) override
Resize the arrays to a given size.
virtual const auxid_set_t & getAuxIDs() const override
Get the types(names) of variables handled by this container.
virtual size_t size() const override
Get the size of the container.
AuxContainer for RODHeader_v1.
Description of RODHeader_v1.
virtual void initialize(uint32_t version, uint32_t sourceId, uint32_t run, uint32_t lvl1Id, uint32_t bcId, uint32_t trigType, uint32_t lvl1DetType, const std::vector< uint32_t > &statusWords, uint32_t nData)
int r
Definition globals.cxx:22
size_t auxid_t
Identifier for a particular aux data item.
Definition AuxTypes.h:27
RODHeaderContainer_v2 RODHeaderContainer
Define the latest version of the RODHeader container.
RODHeaderAuxContainer_v2 RODHeaderAuxContainer
Define the latest version of the RODHeader auxiliary container.
RODHeader_v2 RODHeader
Define the latest version of the RODHeader class.
DataVector< xAOD::RODHeader_v1 > RODHeaderContainer_v1
Define the RODHeader as a simple DataVector.