ATLAS Offline Software
PixelStaveTypes.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 "PixelStaveTypes.h"
7 
9 
10 #include <iostream>
11 #include <algorithm>
12 
13 // Class to store information from PixelStaveTypes and allow easy retrieval.
14 
15 
17 
18 PixelStaveTypes::Datum::Datum(int fluidType_in, int biStaveType_in)
19 : fluidType(fluidType_in),
20  biStaveType(biStaveType_in)
21 {}
22 
23 PixelStaveTypes::Key::Key(int layer_in, int phiModule_in)
24  : layer(layer_in),
25  phiModule(phiModule_in)
26 {}
27 
28 bool
30 {
31  return
32  ((layer < rhs.layer) ||
33  (layer == rhs.layer && phiModule < rhs.phiModule));
34 }
35 
36 
38 {
39  for (unsigned int i = 0; i < db->getTableSize(table); i++) {
40  int layer = db->getInt(table,"LAYER",i);
41  int phiModule = db->getInt(table,"SECTOR",i);
42  int fluidType = db->getInt(table,"FLUIDTYPE",i);
43  int biStaveType = db->getInt(table,"BISTAVETYPE",i);
44 
45  m_dataLookup[Key(layer,phiModule)] = Datum(fluidType,biStaveType);
46  m_maxSector[layer] = std::max(phiModule, m_maxSector[layer]); // Store the max sector for each layer.
47  }
48 }
49 
50 int
52 {
54 }
55 
56 int
58 {
60 }
61 
62 
65 {
66  int layerTmp = layer;
67 
68  // If no entries for layer, use layer 0.
69  std::map<int,int>::const_iterator iterMaxSector;
70  iterMaxSector = m_maxSector.find(layerTmp);
71  if (iterMaxSector == m_maxSector.end() && layerTmp) {
72  layerTmp = 0;
73  iterMaxSector = m_maxSector.find(layerTmp);
74  }
75 
76  if (iterMaxSector != m_maxSector.end()) {
77  int maxSector = iterMaxSector->second;
78  // if phiModule is greater than max Sector in table then assume pattern repeats.
79  // NB This is not the case as the pattern is not very regular and there is an entery
80  // for each layer and phi sector.
81  int phiModuleTmp = phiModule % (maxSector+1);
82 
83  MapType::const_iterator iter;
84  iter = m_dataLookup.find(Key(layerTmp, phiModuleTmp));
85 
86  if (iter != m_dataLookup.end()) return iter->second;
87  }
88 
89  std::cout << "ERROR: PixelStaveTypes cannot find type for layer,phiModule: " << layer << ", " << phiModule << std::endl;
90  return s_defaultDatum;
91 }
92 
PixelStaveTypes::getBiStaveType
int getBiStaveType(int layer, int phiModule) const
Definition: PixelStaveTypes.cxx:57
PixelStaveTypes::Datum::fluidType
int fluidType
Definition: PixelStaveTypes.h:35
max
#define max(a, b)
Definition: cfImp.cxx:41
IGeometryDBSvc.h
PixelStaveTypes::Key
Definition: PixelStaveTypes.h:23
AthenaPoolExample_ReadWrite.Key
Key
Definition: AthenaPoolExample_ReadWrite.py:53
PixelStaveTypes::m_dataLookup
MapType m_dataLookup
Definition: PixelStaveTypes.h:42
CaloCondBlobAlgs_fillNoiseFromASCII.db
db
Definition: CaloCondBlobAlgs_fillNoiseFromASCII.py:43
PixelStaveTypes::Key::layer
int layer
Definition: PixelStaveTypes.h:26
lumiFormat.i
int i
Definition: lumiFormat.py:92
PixelStaveTypes::Key::phiModule
int phiModule
Definition: PixelStaveTypes.h:27
PixelStaveTypes.h
TRT::Hit::layer
@ layer
Definition: HitInfo.h:79
PixelStaveTypes::s_defaultDatum
static const Datum s_defaultDatum
Definition: PixelStaveTypes.h:46
IGeometryDBSvc
Definition: IGeometryDBSvc.h:21
IRDBRecordset_ptr
std::shared_ptr< IRDBRecordset > IRDBRecordset_ptr
Definition: IRDBAccessSvc.h:25
PixelStaveTypes::Key::Key
Key(int layer_in, int phiModule_in)
Definition: PixelStaveTypes.cxx:23
PixelStaveTypes::Datum
Definition: PixelStaveTypes.h:32
PixelStaveTypes::m_maxSector
std::map< int, int > m_maxSector
Definition: PixelStaveTypes.h:44
python.ext.table_printer.table
list table
Definition: table_printer.py:81
PixelStaveTypes::getFluidType
int getFluidType(int layer, int phiModule) const
Definition: PixelStaveTypes.cxx:51
TRT::Hit::phiModule
@ phiModule
Definition: HitInfo.h:80
PixelStaveTypes::Datum::biStaveType
int biStaveType
Definition: PixelStaveTypes.h:36
PixelStaveTypes::Datum::Datum
Datum(int fluidType_in=0, int biStaveType_in=0)
Definition: PixelStaveTypes.cxx:18
IRDBRecordset.h
Definition of the abstract IRDBRecordset interface.
PixelStaveTypes::Key::operator<
bool operator<(const Key &rhs) const
Definition: PixelStaveTypes.cxx:29
PixelStaveTypes::PixelStaveTypes
PixelStaveTypes(const IGeometryDBSvc *db, const IRDBRecordset_ptr &table)
Definition: PixelStaveTypes.cxx:37
PixelStaveTypes::getData
const Datum & getData(int layer, int phiModule) const
Definition: PixelStaveTypes.cxx:64