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