ATLAS Offline Software
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 
13 int 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 
24 void DetCondFloat::share(const Identifier& ident, const int index) {
25  // add object which is pointing to already existing buffer space
27 }
28 
29 const 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 
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 void 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 
57 void DetCondFloat::print2() const {
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 }
python.CaloRecoConfig.f
f
Definition: CaloRecoConfig.py:127
DetCondFloat::add
int add(const Identifier &ident, const float *f)
Definition: DetCondFloat.cxx:13
DetCondFloat::print2
virtual void print2() const
Definition: DetCondFloat.cxx:57
index
Definition: index.py:1
DetCondFloat::m_size
int m_size
Definition: DetCondFloat.h:57
DetCondFloat::findindex
int findindex(const Identifier &ident) const
Definition: DetCondFloat.cxx:40
DetCondFloat::m_bufmap
BufferMap m_bufmap
Definition: DetCondFloat.h:61
DetCondFloat::m_tag
std::string m_tag
Definition: DetCondFloat.h:58
lumiFormat.i
int i
Definition: lumiFormat.py:92
Identifier
Definition: DetectorDescription/Identifier/Identifier/Identifier.h:32
DetCondFloat::share
void share(const Identifier &ident, const int index)
Definition: DetCondFloat.cxx:24
DetCondFloat::print
virtual void print() const
Definition: DetCondFloat.cxx:51
DetCondFloat.h
TRT::Hit::ident
@ ident
Definition: HitInfo.h:77
DeMoScan.index
string index
Definition: DeMoScan.py:362
DetCondFloat::find
const float * find(const Identifier &ident) const
Definition: DetCondFloat.cxx:29
DetCondFloat::m_buf
std::vector< float > m_buf
Definition: DetCondFloat.h:62
fitman.k
k
Definition: fitman.py:528