ATLAS Offline Software
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 
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 }
beamspotman.r
def r
Definition: beamspotman.py:676
xAOD::HIEventShapeAuxContainer_v1
Definition: HIEventShapeAuxContainer_v1.h:14
xAOD::HIEventShapeAuxContainer
HIEventShapeAuxContainer_v2 HIEventShapeAuxContainer
Define the latest version of the auxiliary container.
Definition: HIEventShapeAuxContainer.h:16
SG::AuxTypeRegistry::instance
static AuxTypeRegistry & instance()
Return the singleton registry instance.
Definition: AuxTypeRegistry.cxx:49
xAOD::HIEventShape_v2::setArea
void setArea(float value)
xAOD::HIEventShape_v2::setEtaMin
void setEtaMin(float value)
xAODHIEventShapeAuxContainerCnv_v1::persToTrans
virtual void persToTrans(const xAOD::HIEventShapeAuxContainer_v1 *oldObj, xAOD::HIEventShapeAuxContainer *newObj, MsgStream &log)
Function converting from the old type to the current one.
Definition: xAODHIEventShapeAuxContainerCnv_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
xAOD::HIEventShape_v1
Definition: HIEventShape_v1.h:22
TPConverterBase
Definition: TPConverter.h:738
SG::TypelessConstAccessor
Helper class to provide const generic access to aux data.
Definition: TypelessConstAccessor.h:44
xAOD::HIEventShape_v2::setRho
void setRho(float value)
xAOD
ICaloAffectedTool is abstract interface for tools checking if 4 mom is in calo affected region.
Definition: ICaloAffectedTool.h:24
xAOD::HIEventShape
HIEventShape_v2 HIEventShape
Definition of the latest event info version.
Definition: HIEventShape.h:16
xAOD::HIEventShapeAuxContainer_v2
Auxiliary store for xAOD::HIEventShape_v2.
Definition: HIEventShapeAuxContainer_v2.h:31
xAOD::AuxContainerBase::resize
virtual bool resize(size_t size) override
Resize the arrays to a given size.
Definition: AuxContainerBase.cxx:485
xAOD::HIEventShape_v2::setEtSin
void setEtSin(const std::vector< float > &value)
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
xAOD::HIEventShape_v2
Interface class for the HI reconstruction EDM.
Definition: HIEventShape_v2.h:31
SG::auxid_t
size_t auxid_t
Identifier for a particular aux data item.
Definition: AuxTypes.h:27
xAOD::HIEventShape_v2::setEtCos
void setEtCos(const std::vector< float > &value)
lumiFormat.i
int i
Definition: lumiFormat.py:92
endmsg
#define endmsg
Definition: AnalysisConfig_Ntuple.cxx:63
HIEventShapeContainer.h
AthenaPoolTestRead.acc
acc
Definition: AthenaPoolTestRead.py:16
SG::AuxElement::index
size_t index() const
Return the index of this element within its container.
DataVector
Derived DataVector<T>.
Definition: DataVector.h:581
ATH_MSG
#define ATH_MSG(MSG)
Convenience macro for printing messages in the converter.
Definition: xAODHIEventShapeAuxContainerCnv_v1.cxx:23
xAODHIEventShapeAuxContainerCnv_v1::transToPers
virtual void transToPers(const xAOD::HIEventShapeAuxContainer *, xAOD::HIEventShapeAuxContainer_v1 *, MsgStream &log)
Dummy function inherited from the base class.
Definition: xAODHIEventShapeAuxContainerCnv_v1.cxx:129
HIEventShapeContainer_v1.h
xAODHIEventShapeAuxContainerCnv_v1.h
DataVector::push_back
value_type push_back(value_type pElem)
Add an element to the end of the collection.
python.CaloCondTools.log
log
Definition: CaloCondTools.py:20
AuxTypeRegistry.h
Handle mappings between names and auxid_t.
xAOD::HIEventShape_v2::setNCells
void setNCells(int value)
xAOD::HIEventShape_v2::setEtaMax
void setEtaMax(float value)
xAOD::HIEventShape_v2::setLayer
void setLayer(int value)
xAOD::HIEventShape_v2::setEt
void setEt(float value)
Set the reconstructed transverse energy.
xAODHIEventShapeAuxContainerCnv_v1::xAODHIEventShapeAuxContainerCnv_v1
xAODHIEventShapeAuxContainerCnv_v1()
Default constructor.
Definition: xAODHIEventShapeAuxContainerCnv_v1.cxx:30