ATLAS Offline Software
Loading...
Searching...
No Matches
DetCondFloat.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
3*/
4
5// DetCondFloat.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 DetCondFloat::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 DetCondFloat::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* DetCondFloat::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 DetCondFloat::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
51void DetCondFloat::print() const {
52 std::cout << "DetCondFloat " << m_tag << " has granularity " << m_size <<
53 " with " << m_bufmap.size() << " entries and " << m_buf.size() <<
54 " elements" << std::endl;
55}
56
58 print();
59 int i=0;
60 for (BufferMap::const_iterator itr=m_bufmap.begin();
61 itr!=m_bufmap.end(); ++itr,++i) {
62 int j=itr->second;
63 std::cout << "Element " << i << " ident " << (itr->first).getString() <<
64 "offset " << j << " values:";
65 for (int k=j; k<j+m_size; ++k) std::cout << " " << m_buf[k];
66 std::cout << std::endl;
67 }
68}
int findindex(const Identifier &ident) const
BufferMap m_bufmap
void share(const Identifier &ident, const int index)
std::vector< float > m_buf
int add(const Identifier &ident, const float *f)
virtual void print() const
virtual void print2() const
const float * find(const Identifier &ident) const
std::string m_tag
Definition index.py:1