ATLAS Offline Software
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 
13 int 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 
24 void DetCondCFloat::share(const Identifier& ident, const int index) {
25  // add object which is pointing to already existing buffer space
27 }
28 
29 const 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 
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 
51 float DetCondCFloat::get(const Identifier& ident, int k) const {
52  return m_buf.at(findindex(ident)+k);
53 }
54 
55 void DetCondCFloat::print() const {
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 
61 void DetCondCFloat::print2() const {
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 }
DetCondCFloat::print2
void print2() const
Definition: DetCondCFloat.cxx:61
index
Definition: index.py:1
DetCondCFloat::m_buf
std::vector< float > m_buf
Definition: DetCondCFloat.h:70
DetCondCFloat::findindex
int findindex(const Identifier &ident) const
Definition: DetCondCFloat.cxx:40
DetCondCFloat::share
void share(const Identifier &ident, const int index)
Definition: DetCondCFloat.cxx:24
DetCondCFloat::m_size
int m_size
Definition: DetCondCFloat.h:65
lumiFormat.i
int i
Definition: lumiFormat.py:85
DetCondCFloat::add
int add(const Identifier &ident, const float *f)
Definition: DetCondCFloat.cxx:13
DetCondCFloat::get
float get(const Identifier &ident, int k) const
Definition: DetCondCFloat.cxx:51
hist_file_dump.f
f
Definition: hist_file_dump.py:135
TRT::Hit::ident
@ ident
Definition: HitInfo.h:77
DeMoScan.index
string index
Definition: DeMoScan.py:364
DetCondCFloat::m_bufmap
BufferMap m_bufmap
Definition: DetCondCFloat.h:69
DetCondCFloat::print
void print() const
Definition: DetCondCFloat.cxx:55
DetCondCFloat.h
DetCondCFloat::m_tag
std::string m_tag
Definition: DetCondCFloat.h:66
DetCondCFloat::find
const float * find(const Identifier &ident) const
Definition: DetCondCFloat.cxx:29
fitman.k
k
Definition: fitman.py:528
Identifier
Definition: IdentifierFieldParser.cxx:14