ATLAS Offline Software
EventShape_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 
6 // System include(s):
7 #include <iostream>
8 #include <stdexcept>
9 
10 // Local include(s):
12 
14 #define DEFINE_ACCESSOR( NAME ) \
15  case xAOD::EventShape_v1::NAME: \
16  { \
17  static const SG::AuxElement::Accessor< float > a( #NAME ); \
18  return &a; \
19  } \
20  break
21 
22 namespace {
23 
26  eventShapeAccessor( xAOD::EventShape_v1::EventShapeID id ) {
27 
28  switch( id ) {
29  DEFINE_ACCESSOR( Thrust );
30  DEFINE_ACCESSOR( ThrustEta );
31  DEFINE_ACCESSOR( ThrustPhi );
32  DEFINE_ACCESSOR( ThrustMinor );
33  DEFINE_ACCESSOR( Sphericity );
34  DEFINE_ACCESSOR( FoxWolfram );
35  default:
36  break;
37  }
38 
39  // Complain:
40  std::cerr << "eventShapeAccessor ERROR Received unknown "
41  << "xAOD::EventShape::EventShapeID (" << id << ")" << std::endl;
42  return nullptr;
43  }
44 
47  eventDensityAccessor( xAOD::EventShape_v1::EventDensityID id ) {
48 
49  switch( id ) {
50  DEFINE_ACCESSOR( Density );
51  DEFINE_ACCESSOR( DensitySigma );
52  DEFINE_ACCESSOR( DensityArea );
53  default:
54  break;
55  }
56 
57  // Complain:
58  std::cerr << "eventDensityAccessor ERROR Received unknown "
59  << "xAOD::EventShape::EventDensityID (" << id << ")"
60  << std::endl;
61  return nullptr;
62  }
63 
65  bool getAttribute( const SG::AuxElement::Accessor< float >* acc,
66  const xAOD::EventShape_v1& es, double &v ) {
67 
68  if( acc && acc->isAvailable( es ) ) {
69  v = ( *acc )( es );
70  return true;
71  } else {
72  return false;
73  }
74  }
75 
77  double getAttribute( const SG::AuxElement::Accessor< float >* acc,
78  const xAOD::EventShape_v1& es ) {
79 
80  if( acc ) {
81  return ( *acc )( es );
82  } else {
83  throw std::runtime_error( "Asked for unknown xAOD::EventShape "
84  "property" );
85  }
86  }
87 
89  bool setAttribute( const SG::AuxElement::Accessor< float >* acc,
90  xAOD::EventShape_v1& es, double v ) {
91 
92  if( acc ) {
93  ( *acc )( es ) = v;
94  return true;
95  } else {
96  return false;
97  }
98  }
99 
100 } // private namespace
101 
102 namespace xAOD {
103 
105  : SG::AuxElement() {
106 
107  }
108 
110  //
111  // Implementation of the shape handling function(s)
112 
113  bool EventShape_v1::getShape( EventShapeID id, double& v ) const {
114 
115  return getAttribute( eventShapeAccessor( id ), *this, v );
116  }
117 
119 
120  return getAttribute( eventShapeAccessor( id ), *this );
121  }
122 
124 
125  return setAttribute( eventShapeAccessor( id ), *this, v );
126  }
127 
128  //
130 
132  //
133  // Implementation of the density handling function(s)
134 
135  bool EventShape_v1::getDensity( EventDensityID id, double &v ) const {
136 
137  return getAttribute( eventDensityAccessor( id ), *this, v );
138  }
139 
141 
142  return getAttribute( eventDensityAccessor( id ), *this );
143  }
144 
146 
147  return setAttribute( eventDensityAccessor( id ), *this, v );
148  }
149 
150  //
152 
153 } // namespace xAOD
xAOD::EventShape_v1::getDensity
bool getDensity(EventDensityID id, double &v) const
Get a density variable from the object.
Definition: EventShape_v1.cxx:135
SG
Forward declaration.
Definition: CaloCellPacker_400_500.h:32
SG::Accessor
Helper class to provide type-safe access to aux data.
Definition: Control/AthContainers/AthContainers/Accessor.h:66
xAOD::EventShape_v1::getShape
bool getShape(EventShapeID id, double &v) const
Get a shape variable from the object.
Definition: EventShape_v1.cxx:113
xAOD
ICaloAffectedTool is abstract interface for tools checking if 4 mom is in calo affected region.
Definition: ICaloAffectedTool.h:24
EventShape_v1.h
AthenaPoolTestRead.acc
acc
Definition: AthenaPoolTestRead.py:16
DEFINE_ACCESSOR
#define DEFINE_ACCESSOR(NAME)
Helper macro for managing EventShape Accessor objects.
Definition: EventShape_v1.cxx:14
xAOD::EventShape_v1::EventDensityID
EventDensityID
Event density variable types.
Definition: EventShape_v1.h:45
xAOD::EventShape_v1
Data class for event shapes.
Definition: EventShape_v1.h:28
python.PyAthena.v
v
Definition: PyAthena.py:157
xAOD::EventShape_v1::EventShape_v1
EventShape_v1()
Default constructor.
Definition: EventShape_v1.cxx:104
xAOD::EventShape_v1::EventShapeID
EventShapeID
Event shape variable types.
Definition: EventShape_v1.h:35
xAOD::EventShape_v1::setDensity
bool setDensity(EventDensityID id, double v)
Set a density variable on the object.
Definition: EventShape_v1.cxx:145
xAOD::EventShape_v1::setShape
bool setShape(EventShapeID id, double v)
Set a shape variable on the object.
Definition: EventShape_v1.cxx:123