001 #include "MuonGeoModel/MYSQL.h"
002 #include "MuonReadoutGeometry/GlobalUtilities.h"
003 #include <sstream>
004 #include <iostream>
005 #include <cassert>
006
007 #include "MuonGeoModel/Technology.h"
008 #include "MuonReadoutGeometry/TgcReadoutParams.h"
009
010
011 namespace MuonGM {
012
013 MYSQL* MYSQL::thePointer=0;
014
015 MYSQL::MYSQL()
016 {
017 m_geometry_version = "unknown";
018 m_layout_name = "unknown";
019 m_amdb_version = 0;
020 m_nova_version = 0;
021 m_amdb_from_rdb = false;
022 m_msgSvc = Athena::getMessageSvc();
023
024 for(unsigned int i=0; i<NTgcReadouts; i++) tgcReadout[i]=NULL;
025
026 }
027
028 MYSQL::~MYSQL()
029 {
030
031 std::map<std::string,Station*>::const_iterator it;
032 for (it=stations.begin();it!=stations.end();it++)
033 {
034 delete (*it).second;
035 }
036
037 std::map<std::string,Technology*>::const_iterator it1;
038 for (it1=technologies.begin();it1!=technologies.end();it1++)
039 {
040 delete (*it1).second;
041 }
042
043 thePointer = 0;
044 }
045
046 MYSQL* MYSQL::GetPointer()
047 {
048 if (!thePointer) {
049 thePointer=new MYSQL;
050 std::cout<<MSG::INFO<<"MYSQL singleton created from scratch at location <"<<thePointer<<std::endl;
051 }
052 return thePointer;
053 }
054
055 Station* MYSQL::GetStation(std::string name)
056 {
057 MsgStream log(m_msgSvc, "MuGM:MYSQL");
058
059 if (stations.find(name)!=stations.end())
060 {
061
062 return stations[name];
063 }
064 else return 0;
065 }
066
067 Position MYSQL::GetStationPosition(std::string nameType, int fi, int zi)
068 {
069 MsgStream log(m_msgSvc, "MuGM::MYSQL");
070 Position p;
071
072 int subtype = allocPosFindSubtype(nameType, fi, zi);
073 std::string stname = nameType+MuonGM::buildString(subtype, 0);
074 Station* st = GetStation(stname);
075 if ( st != NULL ) {
076
077 p = (*(st->FindPosition(zi, fi))).second;
078
079 }
080 else
081 {
082 log<<MSG::WARNING<<"::GetStationPosition nothing found for "
083 <<nameType<<" at fi/zi "<<fi<<" "<<zi<<endreq;
084 }
085 return p;
086 }
087
088
089 TgcReadoutParams* MYSQL::GetTgcRPars(std::string name)
090 {
091 MsgStream log(m_msgSvc, "MuGM:MYSQL");
092
093
094 if (tgcReadouts.find(name)!=tgcReadouts.end())
095 {
096 return tgcReadouts[name];
097 }
098 else return NULL;
099 }
100
101 TgcReadoutParams* MYSQL::GetTgcRPars(int jsta)
102 {
103 MsgStream log(m_msgSvc, "MuGM:MYSQL");
104
105
106
107 if (jsta-1<0 || jsta>=NTgcReadouts) {
108 log<<MSG::ERROR<<"MYSQL::GetTgcRPars jsta = "<<jsta<<" out of range (0,"<<NTgcReadouts-1<<")"<<endreq;
109 return NULL;
110 }
111 return tgcReadout[jsta-1];
112 }
113
114 Technology* MYSQL::GetTechnology(std::string name)
115 {
116 MsgStream log(m_msgSvc, "MuGM:MYSQL");
117 if (technologies.find(name)!=technologies.end())
118 {
119
120 return technologies[name];
121 }
122 else
123 {
124
125 return 0;
126 }
127 }
128
129 void MYSQL::StoreTechnology(Technology* t)
130 {
131 MsgStream log(m_msgSvc, "MuGM:MYSQL");
132
133 if (technologies.find(t->GetName())!=technologies.end())
134 {
135 log<<MSG::ERROR
136 <<"MYSQL::StoreTechnology ERROR /// This place is already taken !!! for "
137 <<t->GetName()<<endreq;
138 assert(0);
139 }
140 else technologies[t->GetName()]=t;
141 }
142
143 void MYSQL::StoreStation(Station* s)
144 {
145 MsgStream log(m_msgSvc, "MuGM:MYSQL");
146
147 stations[s->GetName()]=s;
148 }
149 void MYSQL::StoreTgcRPars(TgcReadoutParams* s)
150 {
151 MsgStream log(m_msgSvc, "MuGM:MYSQL");
152 log<<MSG::DEBUG<<"MYSQL::StoreTgcRPars named "<<s->GetName()<<" located @ "<<s<<" jsta = "<<s->chamberType()<<endreq;
153
154 if ( s->chamberType() >= NTgcReadouts)
155 {
156 log<<MSG::ERROR<<"MYSQL::StoreTgcRPars ChamberType(JSTA) "<<s->chamberType() <<" > NTgcReadouts="<<NTgcReadouts<<endreq;
157 return;
158 }
159 tgcReadout[s->chamberType()-1]=s;
160 }
161
162
163 void MYSQL::PrintAllStations()
164 {
165 std::map<std::string,Station*>::const_iterator it;
166 for (it=stations.begin();it!=stations.end();it++)
167 {
168 std::string key=(*it).first;
169
170 std::cout<<"---> Station "<<key<<std::endl;
171 }
172 }
173
174 void MYSQL::PrintTechnologies()
175 {
176 std::map<std::string,Technology* >::const_iterator it;
177 for (it=technologies.begin();it!=technologies.end();it++)
178 {
179 std::string key=(*it).first;
180 std::cout<<"---> Technology "<<key<<std::endl;
181 }
182 }
183 Technology* MYSQL::GetATechnology(std::string name)
184 {
185 MsgStream log(m_msgSvc, "MuGM:MYSQL");
186 if (technologies.find(name)!=technologies.end())
187 {
188
189 return technologies[name];
190 }
191 else
192 {
193
194 for (unsigned int i=1; i<=20; i++)
195 {
196 char chindex[3];
197 sprintf(chindex,"%i",i);
198
199 std::string newname = name.substr(0,3)+MuonGM::buildString(i,2);
200 if (technologies.find(newname)!=technologies.end()) {
201 log<<MSG::DEBUG<<" Selecting a technology called <"<<newname
202 <<">"<<endreq;
203 return technologies[newname];
204 }
205 }
206 return 0;
207 }
208 }
209
210 std::string MYSQL::allocPosBuildKey(std::string statType, int fi, int zi)
211 {
212 MsgStream log(m_msgSvc, "MuGM:MYSQL");
213 std::ostringstream mystream;
214 mystream << statType << "fi" << MuonGM::buildString(fi, 1) << "zi" << MuonGM::buildString(zi, -1);
215
216 return mystream.str();
217 }
218
219 allocPosIterator MYSQL::allocPosFind(std::string statType, int fi, int zi)
220 {
221 std::string key = allocPosBuildKey(statType, fi, zi);
222 return allocPosFind(key);
223 }
224
225 int MYSQL::allocPosFindSubtype(std::string statType, int fi, int zi)
226 {
227 std::string key = allocPosBuildKey(statType, fi, zi);
228 return allocPosFindSubtype(key);
229 }
230
231 int MYSQL::allocPosFindCutout(std::string statType, int fi, int zi)
232 {
233 std::string key = allocPosBuildKey(statType, fi, zi);
234 return allocPosFindCutout(key);
235 }
236
237 void MYSQL::addallocPos(std::string statType, int fi, int zi, int subtyp, int cutout)
238 {
239 std::string key = allocPosBuildKey(statType, fi, zi);
240 addallocPos(key, subtyp, cutout);
241 }
242
243 }
244
| Due to the LXR bug, the updates fail sometimes to remove references to deleted files. The Saturday's full rebuilds fix these problems |
|
This page was automatically generated by the
LXR engine.
|
|