ATLAS Offline Software
PixelMaterialMap.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 #include "PixelMaterialMap.h"
8 
9 #include <iostream>
10 
11 PixelMaterialMap::Key::Key(int layerdisk_in, int typenum_in, const std::string & volumeName_in):
12  layerdisk(layerdisk_in),
13  typenum(typenum_in),
14  volumeName(volumeName_in)
15 {}
16 
17 bool
19 {
20  return
21  ((volumeName < rhs.volumeName) ||
22  (volumeName == rhs.volumeName && layerdisk < rhs.layerdisk) ||
23  (volumeName == rhs.volumeName && layerdisk == rhs.layerdisk && typenum < rhs.typenum));
24 }
25 
26 
28 {
29  for (unsigned int i = 0; i < db->getTableSize(mapTable); i++) {
30  int layerdisk = db->getInt(mapTable,"LAYERDISK",i);
31  int typenum = db->getInt(mapTable,"TYPENUM",i);
32  std::string volumeName = db->getString(mapTable,"VOLUMENAME",i);
33  std::string material = db->getString(mapTable,"MATERIAL",i);
34  addMaterial(layerdisk, typenum, volumeName, material);
35  }
36 }
37 
38 std::string
39 PixelMaterialMap::getMaterial(int layerdisk, int typenum, const std::string & volumeName) const
40 {
41  // If not found try (layerdisk, 0) then (0, typenum), then (0,0)
42  mapType::const_iterator iter;
43  iter = m_matmap.find(Key(layerdisk, typenum, volumeName));
44  if (iter == m_matmap.end() && typenum) {
45  iter = m_matmap.find(Key(layerdisk, 0, volumeName));
46  }
47  if (iter == m_matmap.end() && layerdisk) {
48  iter = m_matmap.find(Key(0, typenum, volumeName));
49  }
50  if (iter == m_matmap.end() && typenum && layerdisk) {
51  iter = m_matmap.find(Key(0, 0, volumeName));
52  }
53  if (iter != m_matmap.end()) {
54  return iter->second;
55  } else {
56  std::cout << "ERROR: PixelMaterialMap::getMaterial Cannot find material for volumeName: " << volumeName << std::endl;
57  return "";
58  }
59 }
60 
61 
62 void
63 PixelMaterialMap::addMaterial(int layerdisk, int typenum, const std::string & volumeName, const std::string & materialName)
64 {
65  m_matmap[Key(layerdisk, typenum, volumeName)] = materialName;
66 }
PixelMaterialMap::addMaterial
void addMaterial(int layerdisk, int typenum, const std::string &volumeName, const std::string &materialName)
Definition: PixelMaterialMap.cxx:63
IGeometryDBSvc.h
AthenaPoolExample_ReadWrite.Key
Key
Definition: AthenaPoolExample_ReadWrite.py:53
CaloCondBlobAlgs_fillNoiseFromASCII.db
db
Definition: CaloCondBlobAlgs_fillNoiseFromASCII.py:43
PixelMaterialMap::Key::Key
Key(int layerdisk_in, int typenum_in, const std::string &volumeName_in)
Definition: PixelMaterialMap.cxx:11
PixelMaterialMap::Key
Definition: PixelMaterialMap.h:27
PixelMaterialMap::getMaterial
std::string getMaterial(int layerdisk, int typenum, const std::string &volumeName) const
Definition: PixelMaterialMap.cxx:39
PixelMaterialMap.h
PixelMaterialMap::Key::operator<
bool operator<(const Key &rhs) const
Definition: PixelMaterialMap.cxx:18
lumiFormat.i
int i
Definition: lumiFormat.py:85
PixelMaterialMap::PixelMaterialMap
PixelMaterialMap(const IGeometryDBSvc *db, const IRDBRecordset_ptr &mapTable)
Definition: PixelMaterialMap.cxx:27
IGeometryDBSvc
Definition: IGeometryDBSvc.h:21
IRDBRecordset_ptr
std::shared_ptr< IRDBRecordset > IRDBRecordset_ptr
Definition: IRDBAccessSvc.h:25
PixelMaterialMap::Key::typenum
int typenum
Definition: PixelMaterialMap.h:31
PixelMaterialMap::Key::volumeName
std::string volumeName
Definition: PixelMaterialMap.h:32
PixelMaterialMap::m_matmap
mapType m_matmap
Definition: PixelMaterialMap.h:37
PixelMaterialMap::Key::layerdisk
int layerdisk
Definition: PixelMaterialMap.h:30
IRDBRecordset.h
Definition of the abstract IRDBRecordset interface.