ATLAS Offline Software
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 
33 {
34 }
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 }
beamspotman.r
def r
Definition: beamspotman.py:676
RODHeaderContainer_v1.h
xAODRODHeaderAuxContainerCnv_v1::transToPers
virtual void transToPers(const xAOD::RODHeaderAuxContainer *, xAOD::RODHeaderAuxContainer_v1 *, MsgStream &log) const override
Dummy function inherited from the base class.
Definition: xAODRODHeaderAuxContainerCnv_v1.cxx:124
SG::AuxTypeRegistry::instance
static AuxTypeRegistry & instance()
Return the singleton registry instance.
Definition: AuxTypeRegistry.cxx:49
xAODRODHeaderAuxContainerCnv_v1::persToTrans
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.
Definition: xAODRODHeaderAuxContainerCnv_v1.cxx:37
xAOD::AuxContainerBase::getAuxIDs
virtual const auxid_set_t & getAuxIDs() const override
Get the types(names) of variables handled by this container.
Definition: AuxContainerBase.cxx:265
SG::TypelessConstAccessor
Helper class to provide const generic access to aux data.
Definition: TypelessConstAccessor.h:44
RODHeaderContainer.h
xAOD::AuxContainerBase::resize
virtual bool resize(size_t size) override
Resize the arrays to a given size.
Definition: AuxContainerBase.cxx:485
SG::AuxTypeRegistry
Handle mappings between names and auxid_t.
Definition: AuxTypeRegistry.h:62
xAOD::AuxContainerBase::size
virtual size_t size() const override
Get the size of the container.
Definition: AuxContainerBase.cxx:410
DiTauMassTools::ignore
void ignore(T &&)
Definition: PhysicsAnalysis/TauID/DiTauMassTools/DiTauMassTools/HelperFunctions.h:54
SG::auxid_t
size_t auxid_t
Identifier for a particular aux data item.
Definition: AuxTypes.h:27
lumiFormat.i
int i
Definition: lumiFormat.py:92
endmsg
#define endmsg
Definition: AnalysisConfig_Ntuple.cxx:63
xAOD::RODHeaderAuxContainer_v2
AuxContainer for RODHeader_v2.
Definition: RODHeaderAuxContainer_v2.h:29
AthenaPoolTestRead.acc
acc
Definition: AthenaPoolTestRead.py:16
xAODRODHeaderAuxContainerCnv_v1::xAODRODHeaderAuxContainerCnv_v1
xAODRODHeaderAuxContainerCnv_v1()
Default constructor.
Definition: xAODRODHeaderAuxContainerCnv_v1.cxx:32
SG::AuxElement::index
size_t index() const
Return the index of this element within its container.
xAOD::RODHeader_v2
Description of RODHeader_v2.
Definition: RODHeader_v2.h:23
DataVector
Derived DataVector<T>.
Definition: DataVector.h:581
DataVector::push_back
value_type push_back(value_type pElem)
Add an element to the end of the collection.
xAOD::RODHeader_v2::initialize
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)
Definition: RODHeader_v2.cxx:33
xAOD::RODHeaderAuxContainer_v1
AuxContainer for RODHeader_v1.
Definition: RODHeaderAuxContainer_v1.h:29
xAOD::RODHeader
RODHeader_v2 RODHeader
Define the latest version of the RODHeader class.
Definition: Event/xAOD/xAODTrigL1Calo/xAODTrigL1Calo/RODHeader.h:14
xAOD::RODHeader_v1
Description of RODHeader_v1.
Definition: RODHeader_v1.h:23
python.CaloCondTools.log
log
Definition: CaloCondTools.py:20
AuxTypeRegistry.h
Handle mappings between names and auxid_t.
ATH_MSG
#define ATH_MSG(MSG)
Convenience macro for printing messages in the converter.
Definition: xAODRODHeaderAuxContainerCnv_v1.cxx:25
xAODRODHeaderAuxContainerCnv_v1.h