ATLAS Offline Software
Loading...
Searching...
No Matches
DetCondCFloat.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2018 CERN for the benefit of the ATLAS collaboration
3*/
4
5// DetCondCFloat.cxx
6// class to hold sets of identifiers and vectors of floats for detector
7// element specific information
8// Richard Hawkings, started 30/1/04
9
10#include <iostream>
12
13int DetCondCFloat::add(const Identifier& ident, const float* f) {
14 // get pointer to added objects
15 size_t j=m_buf.size();
16 // add them in to the buffer
17 m_buf.resize(j+m_size);
18 for (int i=0;i<m_size;++i) m_buf[j+i]=f[i];
19 // put new map entry
20 m_bufmap[ident]=j;
21 return j;
22}
23
24void DetCondCFloat::share(const Identifier& ident, const int index) {
25 // add object which is pointing to already existing buffer space
26 m_bufmap[ident]=index;
27}
28
29const float* DetCondCFloat::find(const Identifier& ident) const {
30 BufferMap::const_iterator itr=m_bufmap.find(ident);
31 if (itr!=m_bufmap.end()) {
32 // return pointer to datastructure
33 return &m_buf[itr->second];
34 } else {
35 // identifier not in map, return null pointer
36 return 0;
37 }
38}
39
40int DetCondCFloat::findindex(const Identifier& ident) const {
41 BufferMap::const_iterator itr=m_bufmap.find(ident);
42 if (itr!=m_bufmap.end()) {
43 // return index in datastructure, for subsequent share call
44 return itr->second;
45 } else {
46 // identifier not in map, return -ve offset to signal error
47 return -1;
48 }
49}
50
51float DetCondCFloat::get(const Identifier& ident, int k) const {
52 return m_buf.at(findindex(ident)+k);
53}
54
56 std::cout << "DetCondCFloat " << m_tag << " has granularity " << m_size <<
57 " with " << m_bufmap.size() << " entries and " << m_buf.size() <<
58 " elements" << std::endl;
59}
60
62 print();
63 int i=0;
64 for (BufferMap::const_iterator itr=m_bufmap.begin();
65 itr!=m_bufmap.end(); ++itr,++i) {
66 int j=itr->second;
67 std::cout << "Element " << i << " ident " << (itr->first).getString() <<
68 "offset " << j << " values:";
69 for (int k=j; k<j+m_size; ++k) std::cout << " " << m_buf[k];
70 std::cout << std::endl;
71 }
72}
const float * find(const Identifier &ident) const
void print() const
std::vector< float > m_buf
void print2() const
std::string m_tag
float get(const Identifier &ident, int k) const
BufferMap m_bufmap
int add(const Identifier &ident, const float *f)
void share(const Identifier &ident, const int index)
int findindex(const Identifier &ident) const
Definition index.py:1