ATLAS Offline Software
MYSQL.h
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 #ifndef MYSQL_H
6 #define MYSQL_H
7 
9 
11 #include "MuonGeoModel/Position.h"
12 #include "MuonGeoModel/Station.h"
15 
16 
17 #include "CxxUtils/LockedPointer.h"
19 
20 #include <map>
21 #include <string>
22 #include <mutex>
23 
24 /*
25  This class holds an std::map of stations* (key = stationName, i.e. BMS5),
26  an std::map of Technologies* (key = RPC20), and an std::map of TgcReadoutParams*.
27  Stations and Technologies are used only to build the geometry (can be deleted
28  after that).
29  TgcReadoutParams are used by the TgcReadoutElements -> must live forever
30  (they belong to the readout geometry).
31  MYSQL is used only to build the geometry - can be deleted as soon as the job is
32  done (in the Factory).
33  It is responsible for releasing the memory allocated by these objects.
34 
35  This is not thread safe!
36 */
37 
38 namespace MuonGM {
39 
40  typedef std::map<int, std::string>::const_iterator AllocposIterator;
41  typedef std::map<std::string, int>::const_iterator allocPosIterator;
42 
43  class MYSQL: public AthMessaging {
44  public:
46 
48  using StationMap = std::map<std::string, std::unique_ptr<Station> >;
49  using StationIterator = StationMap::const_iterator;
50 
51  using TgcReadParsMap = std::map<std::string, GeoModel::TransientConstSharedPtr<TgcReadoutParams>>;
52  using TgcReadParsIterator = TgcReadParsMap::const_iterator;
53 
54  using TechnologyMap = std::map<std::string, std::unique_ptr<Technology>>;
55  using TechnologyIterator = TechnologyMap::const_iterator;
56 
57  ~MYSQL();
58  bool amdb_from_RDB() const;
59  void set_amdb_from_RDB(bool);
60  void setGeometryVersion(const std::string& s);
61  const std::string& getGeometryVersion() const;
62  void setLayoutName(const std::string& s);
63  const std::string& getLayoutName() const;
64  void setNovaVersion(int i);
65  int getNovaVersion() const;
66  void setNovaReadVersion(int i);
67  int getNovaReadVersion() const;
68 
69  const StationMap& stationMap() const;
70  const TgcReadParsMap& tgcReadParsMap() const;
71 
74  AllocposIterator AllocposFind(int) const;
75  std::string AllocposFindName(int) const;
76  void addAllocpos(int i, const std::string& str);
77  // the new ones
78  std::string allocPosBuildKey(const std::string& statType, int fi, int zi) const;
79  int allocPosBuildValue(int subtype, int cutout) const;
82  allocPosIterator allocPosFind(const std::string& key) const;
83  allocPosIterator allocPosFind(const std::string& statType, int fi, int zi) const;
84  int allocPosFindSubtype(const std::string& statType, int fi, int zi) const;
85  int allocPosFindSubtype(const std::string& key) const;
87  int allocPosFindCutout(const std::string& statType, int fi, int zi) const;
88  int allocPosFindCutout(const std::string& key) const;
90 
91  void addallocPos(const std::string& key, int value);
92  void addallocPos(const std::string& statType, int fi, int zi, int subtyp, int cutout);
93  void addallocPos(const std::string& key, int subtype, int cutout);
94 
95  int NStations() const;
96  int NTgcReadTypes() const;
97 
98  static LockedMYSQL GetPointer();
99  const Station* GetStation(const std::string& name) const;
100  Station *GetStation(const std::string& name);
101  Position GetStationPosition(const std::string& nameType, int fi, int zi) const;
104 
105  void StoreStation(Station* s);
106  void PrintAllStations() const;
109  Technology *GetTechnology(const std::string& name);
110  const Technology *GetTechnology(const std::string& name) const;
111  const Technology *GetATechnology(const std::string& name) const;
112  void PrintTechnologies();
113 
114  // singleton
115  private:
116  // Protects s_thePointer.
117  struct MYSQLPtr
118  {
119  std::recursive_mutex m_mutex;
120  MYSQL* m_ptr{nullptr};
121  };
122  static MYSQLPtr& GetMYSQLPtr();
123 
124  MYSQL();
125  std::map<int, std::string> m_allocatedpos;
126  std::map<std::string, int> m_allocPos;
130  std::array<GeoModel::TransientConstSharedPtr<TgcReadoutParams>, NTgcReadouts> m_tgcReadout{};
131 
132 
133  std::string m_geometry_version{"unknown"}; // from our job-option
134  std::string m_layout_name{"unknown"}; // from nova
135  std::string m_DBMuonVersion{"unknown"}; // name of the MuonVersion table-collection in Oracle
138  bool m_amdb_from_rdb{false};
139  };
140 
141 
142 
143 } // namespace MuonGM
144 
145 #endif
MuonGM::MYSQL::setLayoutName
void setLayoutName(const std::string &s)
Definition: MYSQL.cxx:289
MuonGM::MYSQL::GetTechnology
Technology * GetTechnology(const std::string &name)
Definition: MYSQL.cxx:105
MuonGM::MYSQL::AllocposBegin
AllocposIterator AllocposBegin() const
Definition: MYSQL.cxx:214
MuonGM::MYSQL::m_amdb_from_rdb
bool m_amdb_from_rdb
Definition: MYSQL.h:138
GeoModel::TransientConstSharedPtr< TgcReadoutParams >
MuonGM::MYSQL::TgcReadoutRange
TgcReadoutRange
Definition: MYSQL.h:45
MuonGM
Ensure that the Athena extensions are properly loaded.
Definition: GeoMuonHits.h:27
python.SystemOfUnits.s
int s
Definition: SystemOfUnits.py:131
MuonGM::MYSQL::getNovaReadVersion
int getNovaReadVersion() const
Definition: MYSQL.cxx:260
checkxAOD.nameType
nameType
Definition: Tools/PyUtils/bin/checkxAOD.py:188
MuonGM::allocPosIterator
std::map< std::string, int >::const_iterator allocPosIterator
Definition: MYSQL.h:41
MuonGM::MYSQL::m_allocPos
std::map< std::string, int > m_allocPos
Definition: MYSQL.h:126
MuonGM::MYSQL::allocPosEnd
allocPosIterator allocPosEnd() const
Definition: MYSQL.cxx:238
CxxUtils::LockedPointer
A pointer together with a movable lock.
Definition: LockedPointer.h:35
MuonGM::MYSQL::allocPosFindSubtype
int allocPosFindSubtype(const std::string &statType, int fi, int zi) const
Definition: MYSQL.cxx:196
MuonGM::MYSQL::setNovaVersion
void setNovaVersion(int i)
Definition: MYSQL.cxx:300
MuonGM::MYSQL::GetStation
const Station * GetStation(const std::string &name) const
Definition: MYSQL.cxx:51
MuonGM::MYSQL::MYSQLPtr::m_ptr
MYSQL * m_ptr
Definition: MYSQL.h:120
MuonGM::MYSQL::tgcReadParsMap
const TgcReadParsMap & tgcReadParsMap() const
Definition: MYSQL.cxx:228
MuonGM::Station
Definition: Station.h:40
skel.it
it
Definition: skel.GENtoEVGEN.py:396
MuonGM::MYSQL::PrintTechnologies
void PrintTechnologies()
Definition: MYSQL.cxx:156
MuonGM::MYSQL::AllocposEnd
AllocposIterator AllocposEnd() const
Definition: MYSQL.cxx:212
MuonGM::MYSQL
Definition: MYSQL.h:43
athena.value
value
Definition: athena.py:124
MuonGM::MYSQL::getLayoutName
const std::string & getLayoutName() const
Definition: MYSQL.cxx:262
MuonGM::MYSQL::m_amdb_version
int m_amdb_version
Definition: MYSQL.h:137
MuonGM::Technology
Definition: Technology.h:15
read_hist_ntuple.t
t
Definition: read_hist_ntuple.py:5
MuonGM::MYSQL::m_tgcReadouts
TgcReadParsMap m_tgcReadouts
Definition: MYSQL.h:129
MuonGM::MYSQL::allocPosFindCutout
int allocPosFindCutout(const std::string &statType, int fi, int zi) const
Definition: MYSQL.cxx:201
MuonGM::MYSQL::GetStationPosition
Position GetStationPosition(const std::string &nameType, int fi, int zi) const
Definition: MYSQL.cxx:71
TgcReadoutParams.h
Station.h
MuonGM::MYSQL::m_layout_name
std::string m_layout_name
Definition: MYSQL.h:134
MuonGM::MYSQL::~MYSQL
~MYSQL()
Definition: MYSQL.cxx:23
MuonGM::MYSQL::m_geometry_version
std::string m_geometry_version
Definition: MYSQL.h:133
MuonGM::MYSQL::m_nova_version
int m_nova_version
Definition: MYSQL.h:136
MuonGM::MYSQL::setGeometryVersion
void setGeometryVersion(const std::string &s)
Definition: MYSQL.cxx:271
MuonGM::MYSQL::StoreTgcRPars
void StoreTgcRPars(GeoModel::TransientConstSharedPtr< TgcReadoutParams > t)
Definition: MYSQL.cxx:141
MuonGM::MYSQL::PrintAllStations
void PrintAllStations() const
Definition: MYSQL.cxx:150
MuonGM::Position
Definition: Position.h:11
lumiFormat.i
int i
Definition: lumiFormat.py:85
MuonGM::MYSQL::addAllocpos
void addAllocpos(int i, const std::string &str)
Definition: MYSQL.cxx:210
LockedPointer.h
A pointer together with a movable lock.
MuonGM::MYSQL::getGeometryVersion
const std::string & getGeometryVersion() const
Definition: MYSQL.cxx:258
MuonGM::MYSQL::m_DBMuonVersion
std::string m_DBMuonVersion
Definition: MYSQL.h:135
MuonGM::MYSQL::allocPosBegin
allocPosIterator allocPosBegin() const
Definition: MYSQL.cxx:236
MuonGM::MYSQL::allocPosBuildValue
int allocPosBuildValue(int subtype, int cutout) const
Definition: MYSQL.cxx:234
AthMessaging
Class to provide easy MsgStream access and capabilities.
Definition: AthMessaging.h:55
MuonGM::MYSQL::NTgcReadTypes
int NTgcReadTypes() const
Definition: MYSQL.cxx:232
MuonGM::MYSQL::set_amdb_from_RDB
void set_amdb_from_RDB(bool)
Definition: MYSQL.cxx:268
GlobalUtilities.h
MuonGM::AllocposIterator
std::map< int, std::string >::const_iterator AllocposIterator
Definition: MYSQL.h:40
MuonGM::MYSQL::m_technologies
TechnologyMap m_technologies
Definition: MYSQL.h:128
MuonGM::MYSQL::m_allocatedpos
std::map< int, std::string > m_allocatedpos
Definition: MYSQL.h:125
MuonGM::MYSQL::NTgcReadouts
@ NTgcReadouts
Definition: MYSQL.h:45
MuonGM::MYSQL::amdb_from_RDB
bool amdb_from_RDB() const
Definition: MYSQL.cxx:266
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:228
MuonGM::MYSQL::AllocposFind
AllocposIterator AllocposFind(int) const
Definition: MYSQL.cxx:216
MuonGM::MYSQL::MYSQL
MYSQL()
Definition: MYSQL.cxx:20
MuonGM::MYSQL::MYSQLPtr::m_mutex
std::recursive_mutex m_mutex
Definition: MYSQL.h:119
MuonGM::MYSQL::GetPointer
static LockedMYSQL GetPointer()
Definition: MYSQL.cxx:42
MuonGM::MYSQL::addallocPos
void addallocPos(const std::string &key, int value)
Definition: MYSQL.cxx:254
MuonGM::MYSQL::m_tgcReadout
std::array< GeoModel::TransientConstSharedPtr< TgcReadoutParams >, NTgcReadouts > m_tgcReadout
Definition: MYSQL.h:130
MuonGM::MYSQL::setNovaReadVersion
void setNovaReadVersion(int i)
Definition: MYSQL.cxx:284
Position.h
MuonGM::MYSQL::TgcReadParsMap
std::map< std::string, GeoModel::TransientConstSharedPtr< TgcReadoutParams > > TgcReadParsMap
Definition: MYSQL.h:51
MuonGM::MYSQL::StoreTechnology
void StoreTechnology(Technology *t)
Definition: MYSQL.cxx:125
MuonGM::MYSQL::StationMap
std::map< std::string, std::unique_ptr< Station > > StationMap
Definition: MYSQL.h:48
TransientConstSharedPtr.h
MuonGM::MYSQL::GetATechnology
const Technology * GetATechnology(const std::string &name) const
Definition: MYSQL.cxx:162
AthMessaging.h
MuonGM::MYSQL::allocPosFind
allocPosIterator allocPosFind(const std::string &key) const
Definition: MYSQL.cxx:240
MuonGM::MYSQL::StoreStation
void StoreStation(Station *s)
Definition: MYSQL.cxx:136
checkFileSG.fi
fi
Definition: checkFileSG.py:65
MuonGM::MYSQL::getNovaVersion
int getNovaVersion() const
Definition: MYSQL.cxx:264
MuonGM::MYSQL::GetTgcRPars
GeoModel::TransientConstSharedPtr< TgcReadoutParams > GetTgcRPars(const std::string &name) const
Definition: MYSQL.cxx:88
str
Definition: BTagTrackIpAccessor.cxx:11
MuonGM::MYSQL::allocPosBuildKey
std::string allocPosBuildKey(const std::string &statType, int fi, int zi) const
Definition: MYSQL.cxx:184
MuonGM::MYSQL::TechnologyIterator
TechnologyMap::const_iterator TechnologyIterator
Definition: MYSQL.h:55
MuonGM::MYSQL::NStations
int NStations() const
Definition: MYSQL.cxx:230
MuonGM::MYSQL::GetMYSQLPtr
static MYSQLPtr & GetMYSQLPtr()
Definition: MYSQL.cxx:32
MuonGM::MYSQL::m_stations
StationMap m_stations
Definition: MYSQL.h:127
Technology.h
subproc.subtype
string subtype
Definition: subproc.py:19
MuonGM::MYSQL::AllocposFindName
std::string AllocposFindName(int) const
Definition: MYSQL.cxx:218
MuonGM::MYSQL::stationMap
const StationMap & stationMap() const
Definition: MYSQL.cxx:227
MuonGM::MYSQL::TgcReadParsIterator
TgcReadParsMap::const_iterator TgcReadParsIterator
Definition: MYSQL.h:52
MuonGM::MYSQL::TechnologyMap
std::map< std::string, std::unique_ptr< Technology > > TechnologyMap
Definition: MYSQL.h:54
mapkey::key
key
Definition: TElectronEfficiencyCorrectionTool.cxx:37
MuonGM::MYSQL::StationIterator
StationMap::const_iterator StationIterator
Definition: MYSQL.h:49
MuonGM::MYSQL::MYSQLPtr
Definition: MYSQL.h:118