ATLAS Offline Software
Loading...
Searching...
No Matches
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$
14
15
18#include <set>
19#include <cmath>
20
21
22namespace 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{
29public:
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. */
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 }
58private:
59 const std::vector<float>& m_v;
60};
61
62
63class Utils
64{
65public:
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
Base class for elements of a container that can have aux data.
Helper for iterating over STL map classes.
Helper for iterating over STL map classes.
const std::vector< float > & m_v
SafeFloatAccess(const std::vector< float > &v)
double operator[](size_t i)
static std::vector< unsigned int > getAuxIDVector(const SG::AuxElement &e)
static std::vector< unsigned int > getAuxIDVector(const SG::AuxVectorData &e)
Base class for elements of a container that can have aux data.
Definition AuxElement.h:483
Manage lookup of vectors of auxiliary data.
A set of aux data identifiers.
Definition AuxTypes.h:47
void sort(typename DataModel_detail::iterator< DVL > beg, typename DataModel_detail::iterator< DVL > end)
Specialization of sort for DataVector/List.
PyDumper::PySTLAdaptor< std::set< unsigned int > > s
PyDumper::PySTLAdaptor< std::set< unsignedint > >::iterator s_i
struct PyDumper::SafeFloatAccess::ieee754_float::@060255103051114047334315152077073344367140163323 ieee