ATLAS Offline Software
Loading...
Searching...
No Matches
xAODHIEventShapeAuxContainerCnv_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// System include(s):
6#include <stdexcept>
7
8// Gaudi/Athena include(s):
9#include "GaudiKernel/MsgStream.h"
10
11// EDM include(s):
15
16// Local include(s):
18
20#define MSGLVL MSG::DEBUG
21
23#define ATH_MSG( MSG ) \
24 do { \
25 if( log.level() <= MSGLVL ) { \
26 log << MSGLVL << MSG << endmsg; \
27 } \
28 } while( 0 )
29
31 : T_AthenaPoolTPCnvBase< xAOD::HIEventShapeAuxContainer,
32 xAOD::HIEventShapeAuxContainer_v1 >() {
33
34}
35
39 MsgStream& log ) {
40
41 // Greet the user:
42 ATH_MSG( "Converting xAOD::HIEventShapeAuxContainer_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::HIEventShape_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::HIEventShape_v1* oldES : oldInt ) {
59
60 // Create an object for the new container:
62 newInt.push_back( newES );
63
64 // Copy all the variables that the interface knows about:
65 newES->setEt( oldES->Et() );
66 newES->setArea( oldES->area() );
67 newES->setRho( oldES->rho() );
68 newES->setNCells( oldES->nCells() );
69
70 newES->setEtCos( oldES->Et_cos() );
71 newES->setEtSin( oldES->Et_sin() );
72
73 newES->setEtaMin( oldES->etaMin() );
74 newES->setEtaMax( oldES->etaMax() );
75 newES->setLayer( oldES->layer() );
76
77 // Helper objects to access the auxiliary IDs of the base variables:
78 static const SG::AuxElement::TypelessConstAccessor accEt( "Et" );
79 static const SG::AuxElement::TypelessConstAccessor accArea( "area" );
80 static const SG::AuxElement::TypelessConstAccessor accRho( "rho" );
81 static const SG::AuxElement::TypelessConstAccessor accEt_cos( "Et_cos" );
82 static const SG::AuxElement::TypelessConstAccessor accEt_sin( "Et_sin" );
83 static const SG::AuxElement::TypelessConstAccessor accEtaMin( "etaMin" );
84 static const SG::AuxElement::TypelessConstAccessor accEtaMax( "etaMax" );
85 static const SG::AuxElement::TypelessConstAccessor accLayer( "layer" );
86 static const SG::AuxElement::TypelessConstAccessor accNCells( "nCells" );
87 static const std::array< const SG::AuxElement::TypelessConstAccessor*, 9 >
88 knownVars{ { &accEt, &accArea, &accRho, &accEt_cos, &accEt_sin,
89 &accEtaMin, &accEtaMax, &accLayer, &accNCells } };
90
91 // The index of the objects in their respective containers:
92 const size_t oindex = oldES->index();
93 const size_t nindex = newES->index();
94
95 // The auxiliary registry, used in the copying:
97
98 // Now copy over all the dynamic variables, which were not covered
99 // by the previous lines:
100 for( SG::auxid_t auxid : oldObj->getAuxIDs() ) {
101
102 // Ignore the ones that we already copied:
103 bool ignore = false;
104 for( const auto * acc : knownVars ) {
105 if( auxid == acc->auxid() ) {
106 ignore = true;
107 break;
108 }
109 }
110 if( ignore ) {
111 continue;
112 }
113
114 // Copy the variable:
115 r.copy( auxid, newInt, nindex, oldInt, oindex, 1 );
116 }
117 }
118
119 // Tell the user what happened:
120 ATH_MSG( "Converting xAOD::HIEventShapeAuxContainer_v1 to current version "
121 "[OK]" );
122
123 // Return gracefully:
124 return;
125}
126
131 MsgStream& log ) {
132
133 log << MSG::ERROR << "xAODHIEventShapeAuxContainerCnv_v1::transToPers got "
134 << "called" << endmsg;
135 throw std::runtime_error( "xAODHIEventShapeAuxContainerCnv_v1::transToPers "
136 "got called" );
137
138 return;
139}
#define endmsg
#define ATH_MSG(lvl)
Handle mappings between names and auxid_t.
TPConverterBase< TRANS, PERS > T_AthenaPoolTPCnvBase
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::HIEventShapeAuxContainer_v1 *oldObj, xAOD::HIEventShapeAuxContainer *newObj, MsgStream &log)
Function converting from the old type to the current one.
virtual void transToPers(const xAOD::HIEventShapeAuxContainer *, xAOD::HIEventShapeAuxContainer_v1 *, MsgStream &log)
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.
void setEtCos(const std::vector< float > &value)
set the cosine harmonic modulation
void setEtaMin(float value)
set eta slice "left" edge
void setArea(float value)
set the area of the eta slice
void setEt(float value)
Set the reconstructed transverse energy.
void setLayer(int value)
set layer information
void setEtaMax(float value)
set eta slice "right" edge
void setNCells(int value)
set the number of cells summed in slice
void setEtSin(const std::vector< float > &value)
set the sine harmonic modulation
void setRho(float value)
set the rho value
int r
Definition globals.cxx:22
size_t auxid_t
Identifier for a particular aux data item.
Definition AuxTypes.h:27
ICaloAffectedTool is abstract interface for tools checking if 4 mom is in calo affected region.
HIEventShapeAuxContainer_v2 HIEventShapeAuxContainer
Define the latest version of the auxiliary container.
DataVector< HIEventShape_v1 > HIEventShapeContainer_v1
Container type for event info objects.
HIEventShapeContainer_v2 HIEventShapeContainer
Define the latest version of the container.
HIEventShape_v2 HIEventShape
Definition of the latest event info version.