ATLAS Offline Software
PyDumperDict.h
Go to the documentation of this file.
1 // This file's extension implies that it's C, but it's really -*- C++ -*-.
2 
3 /*
4  Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
5 */
6 
7 // $Id$
16 #include "PyDumper/PySTLAdaptor.h"
18 #include <set>
19 #include <cmath>
20 
21 
22 namespace PyDumper {
23 
24 // Hack to return a float nan to python as a double nan without causing a FPE.
25 // Not doing anything will trap in pyroot.
26 // isnan() can also trap, so don't use that!
28 {
29 public:
31  {
32  float f;
33 
34  /* This is the IEEE 754 single-precision format. */
35  struct
36  {
37 #if __BYTE_ORDER == __BIG_ENDIAN
38  unsigned int negative:1;
39  unsigned int exponent:8;
40  unsigned int mantissa:23;
41 #endif /* Big endian. */
42 #if __BYTE_ORDER == __LITTLE_ENDIAN
43  unsigned int mantissa:23;
44  unsigned int exponent:8;
45  unsigned int negative:1;
46 #endif /* Little endian. */
47  } ieee;
48  };
49 
50  SafeFloatAccess (const std::vector<float>& v) : m_v(v) {}
51  double operator[] (size_t i) {
53  ff.f = m_v[i];
54  if (ff.ieee.exponent == 0xff)
55  return std::nan("");
56  return m_v[i];
57  }
58 private:
59  const std::vector<float>& m_v;
60 };
61 
62 
63 class Utils
64 {
65 public:
66  static
67  std::vector<unsigned int> getAuxIDVector (const SG::AuxVectorData& e)
68  {
69  const SG::auxid_set_t& ids = e.getAuxIDs();
70  std::vector<unsigned int> v (ids.begin(), ids.end());
71  std::sort (v.begin(), v.end());
72  return v;
73  }
74  static
75  std::vector<unsigned int> getAuxIDVector (const SG::AuxElement& e)
76  {
77  const SG::auxid_set_t& ids = e.getAuxIDs();
78  std::vector<unsigned int> v (ids.begin(), ids.end());
79  std::sort (v.begin(), v.end());
80  return v;
81  }
82 };
83 
84 
85 }
86 
87 
88 
89 struct PyDumperDict {
93 };
xAOD::iterator
JetConstituentVector::iterator iterator
Definition: JetConstituentVector.cxx:68
AllowedVariables::e
e
Definition: AsgElectronSelectorTool.cxx:37
PyDumper::SafeFloatAccess::ieee754_float::negative
unsigned int negative
Definition: PyDumperDict.h:38
PyDumper::Utils::getAuxIDVector
static std::vector< unsigned int > getAuxIDVector(const SG::AuxVectorData &e)
Definition: PyDumperDict.h:67
PyDumperDict::PyDumperDict
PyDumperDict()
PyDumper::PySTLAdaptor
Helper for iterating over STL map classes.
Definition: PySTLAdaptor.h:37
PyDumper::SafeFloatAccess
Definition: PyDumperDict.h:28
PyDumper::SafeFloatAccess::ieee754_float::exponent
unsigned int exponent
Definition: PyDumperDict.h:39
SG::AuxElement
Base class for elements of a container that can have aux data.
Definition: AuxElement.h:472
PyDumper::SafeFloatAccess::operator[]
double operator[](size_t i)
Definition: PyDumperDict.h:51
PyDumper
Definition: PyDumperDict.h:22
PyDumper::SafeFloatAccess::ieee754_float
Definition: PyDumperDict.h:31
PyDumperDict::s
PyDumper::PySTLAdaptor< std::set< unsigned int > > s
Definition: PyDumperDict.h:91
PyDumperDict
Definition: PyDumperDict.h:89
PyDumper::SafeFloatAccess::ieee754_float::ieee
struct PyDumper::SafeFloatAccess::ieee754_float::@44 ieee
PyDumper::Utils::getAuxIDVector
static std::vector< unsigned int > getAuxIDVector(const SG::AuxElement &e)
Definition: PyDumperDict.h:75
PyDumper::SafeFloatAccess::ieee754_float::f
float f
Definition: PyDumperDict.h:32
lumiFormat.i
int i
Definition: lumiFormat.py:85
D3PDSizeSummary.ff
ff
Definition: D3PDSizeSummary.py:305
PyDumper::SafeFloatAccess::m_v
const std::vector< float > & m_v
Definition: PyDumperDict.h:59
PyDumper::SafeFloatAccess::ieee754_float::mantissa
unsigned int mantissa
Definition: PyDumperDict.h:40
PyDumper::SafeFloatAccess::SafeFloatAccess
SafeFloatAccess(const std::vector< float > &v)
Definition: PyDumperDict.h:50
python.subdetectors.mmg.ids
ids
Definition: mmg.py:8
PyDumperDict::s_i
PyDumper::PySTLAdaptor< std::set< unsigned int > >::iterator s_i
Definition: PyDumperDict.h:92
python.PyAthena.v
v
Definition: PyAthena.py:154
PySTLAdaptor.h
Helper for iterating over STL map classes.
SG::auxid_set_t
A set of aux data identifiers.
Definition: AuxTypes.h:47
SG::AuxVectorData
Manage lookup of vectors of auxiliary data.
Definition: AuxVectorData.h:168
Utils
Definition: CaloCellSelectorUtils.cxx:10
AuxElement.h
Base class for elements of a container that can have aux data.