001
002 #include "MuonGeoModel/SaddleTubsBuilder.h"
003 #include "AthenaKernel/getMessageSvc.h"
004
005 #include "RDBAccessSvc/IRDBRecord.h"
006 #include "RDBAccessSvc/IRDBRecordset.h"
007 #include "RDBAccessSvc/IRDBAccessSvc.h"
008
009 #include "MuonGeoModel/ArrayFunction.h"
010
011 #include "GeoModelKernel/GeoBox.h"
012 #include "GeoModelKernel/GeoTube.h"
013 #include "GeoModelKernel/GeoTubs.h"
014 #include "GeoModelKernel/GeoPcon.h"
015 #include "GeoModelKernel/GeoTrd.h"
016 #include "GeoModelKernel/GeoTrap.h"
017 #include "GeoModelKernel/GeoPara.h"
018 #include "GeoModelKernel/GeoPgon.h"
019 #include "GeoModelKernel/GeoSimplePolygonBrep.h"
020 #include "GeoModelKernel/GeoMaterial.h"
021 #include "GeoModelKernel/GeoLogVol.h"
022 #include "GeoModelKernel/GeoPhysVol.h"
023 #include "GeoModelKernel/GeoFullPhysVol.h"
024 #include "GeoModelKernel/GeoTransform.h"
025 #include "GeoModelKernel/GeoAlignableTransform.h"
026 #include "GeoModelKernel/GeoNameTag.h"
027 #include "GeoModelKernel/GeoShapeShift.h"
028 #include "GeoModelKernel/GeoShapeUnion.h"
029 #include "GeoModelKernel/GeoShapeSubtraction.h"
030 #include "GeoModelKernel/GeoSerialTransformer.h"
031 #include "GeoModelKernel/GeoIdentifierTag.h"
032 #include "GeoModelSvc/StoredMaterialManager.h"
033
034 #include "StoreGate/StoreGateSvc.h"
035 #include "CLHEP/GenericFunctions/Variable.hh"
036
037 #include <stdexcept>
038 #include <vector>
039 #include <iomanip>
040
041 #include <sstream>
042 typedef std::stringstream my_sstream;
043 typedef std::ostringstream my_osstream;
044
045 using namespace Genfun;
046 using namespace GeoXF;
047
048 namespace MuonGM {
049 SaddleTubsBuilder::SaddleTubsBuilder( StoreGateSvc *pDetStore,
050 IRDBAccessSvc *pRDBAccess,
051 std::string geoTag,
052 std::string geoNode ) :
053 m_pRDBAccess(pRDBAccess),
054 m_pDetStore (pDetStore)
055 {
056
057 _unavailableData = false;
058
059
060
061
062
063
064
065
066
067
068
069
070 m_Saddletuvp = pRDBAccess->getRecordset("SADDLETUVP", geoTag, geoNode);
071 m_Saddletuvs = pRDBAccess->getRecordset("SADDLETUVS",geoTag, geoNode);
072 m_Saddletuvn = pRDBAccess->getRecordset("SADDLETUVN",geoTag, geoNode);
073
074
075
076
077
078
079
080 m_Saddle = pRDBAccess->getRecordset("SADDLE",geoTag, geoNode);
081 if (m_Saddle->size()*m_Saddletuvn->size()*m_Saddletuvs->size()*m_Saddletuvp->size() == 0) _unavailableData=true;
082
083 std::string Iron = "Iron";
084
085 std::string Aluminium = "Alum";
086
087 MsgStream log( Athena::getMessageSvc(), "MuGM:SaddleTubsBuilder" );
088 if (!_unavailableData) log << MSG::INFO << "All data fetched with tag <" << geoTag << ">" << endreq;
089 else log << MSG::INFO << "No data found with tag <" << geoTag << ">" << endreq;
090 }
091
092 void SaddleTubsBuilder::buildSaddleTubs( GeoPhysVol* container )
093 {
094
095 const StoredMaterialManager* theMaterialManager;
096 if ( StatusCode::SUCCESS != m_pDetStore->retrieve( theMaterialManager, "MATERIALS" ) )
097 {
098 return;
099 }
100 int n = 0;
101 int f = 0;
102 int g = 0;
103
104
105 int Numtubs = (int)(*m_Saddle)[0]->getFloat("SADL_NUMTUBES");
106
107 double Xposb[100];
108 double Yposb[100];
109 double Zposb[100];
110 double Xposgl[100];
111 double Yposgl[100];
112 double Zposgl[100];
113 double Rotx[100];
114 double Roty[100];
115 double Rotz[100];
116 for (int k = 0; k < Numtubs; k++)
117 {
118
119 int NumVol = (int)(*m_Saddletuvn)[k]->getFloat("NUMVOL");
120 int Numembo = (int)(*m_Saddletuvn)[k]->getFloat("NUMEMBO");
121 int Numemtu = (int)(*m_Saddletuvn)[k]->getFloat("NUMEMTU");
122
123 int SymX = (int)(*m_Saddletuvn)[k]->getFloat("SYMX");
124 int SymY = (int)(*m_Saddletuvn)[k]->getFloat("SYMY");
125 int SymZ = (int)(*m_Saddletuvn)[k]->getFloat("SYMZ");
126
127
128 float Rmin = (*m_Saddletuvs)[k]->getFloat("RMIN") * mm;
129 float Rmax = (*m_Saddletuvs)[k]->getFloat("RMAX") * mm;
130 float Dz = (*m_Saddletuvs)[k]->getFloat("DZ") * mm;
131 float AlphaStart = (*m_Saddletuvs)[k]->getFloat("ALPHASTART") * mm;
132 float Alpha = (*m_Saddletuvs)[k]->getFloat("ALPHA") * mm;
133
134
135
136 const std::string saddleMaterial = getMaterial( "Iron" );
137
138
139
140
141
142
143
144
145
146
147
148
149
150 GeoTubs* Tubs = new GeoTubs(Rmin , Rmax, Dz/2, AlphaStart * M_PI/180, Alpha * M_PI/180);
151
152
153 const GeoShape* sTubs = &( *Tubs );
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184 f = f + Numemtu;
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208 g = g + Numembo;
209
210 for (int j = n; j < NumVol + n; j++)
211 {
212 Zposgl[j] = (*m_Saddletuvp)[j]->getFloat("ZPOSGL") * mm;
213 Xposgl[j] = (*m_Saddletuvp)[j]->getFloat("XPOSGL") * mm;
214 Yposgl[j] = (*m_Saddletuvp)[j]->getFloat("YPOSGL") * mm;
215 Zposb[j] = (*m_Saddletuvp)[j]->getFloat("ZPOSB") * mm;
216 Xposb[j] = (*m_Saddletuvp)[j]->getFloat("XPOSB") * mm;
217 Yposb[j] = (*m_Saddletuvp)[j]->getFloat("YPOSB") * mm;
218 Rotx[j] = (*m_Saddletuvp)[j]->getFloat("ROTX") * deg;
219 Roty[j] = (*m_Saddletuvp)[j]->getFloat("ROTY") * deg;
220 Rotz[j] = (*m_Saddletuvp)[j]->getFloat("ROTZ") * deg;
221
222
223
224
225 HepTransform3D trlTubs = HepRotateY3D(Roty[j])
226 * HepRotateZ3D(Rotz[j]) * HepRotateX3D(Rotx[j]);
227
228 const GeoShape& posTubsPlate = ( *sTubs << trlTubs );
229
230 GeoLogVol* lTubsPlate = new GeoLogVol( "SaddleTubs",
231 &posTubsPlate,
232 theMaterialManager->getMaterial(saddleMaterial) );
233 GeoPhysVol* pTubsPlate = new GeoPhysVol(lTubsPlate);
234
235
236
237
238
239 int nXpos = SymX + 1;
240 int nYpos = SymY + 1;
241 int nZpos = SymZ + 1;
242
243
244
245 double rotAngleX[2] = { 0, M_PI }; double xPosTubsPlate[2] = {Xposgl[j]+Xposb[j], -Xposgl[j]-Xposb[j]};
246 double rotAngleY[2] = { 0, M_PI }; double yPosTubsPlate[2] = {Yposgl[j]+Yposb[j], -Yposgl[j]-Yposb[j]};
247 double rotAngleZ[2] = { 0, M_PI }; double zPosTubsPlate[2] = {Zposgl[j]+Zposb[j], -Zposgl[j]-Zposb[j]};
248 const int nAllpos = nXpos * nYpos * nZpos;
249
250
251 double zPosTubsAux[100], xPosTubsAux[100], yPosTubsAux[100],
252 rotAngleTubsAuxX[100], rotAngleTubsAuxY[100], rotAngleTubsAuxZ[100];
253
254 for ( int w = 0; w < nAllpos; w++ )
255 {
256 int ww = w % (nAllpos / nZpos),
257 ss = w / (nAllpos / nXpos),
258 ee = w / (nAllpos / nYpos);
259
260
261
262 zPosTubsAux[w] = zPosTubsPlate[ww];
263
264 xPosTubsAux[w] = xPosTubsPlate[ss];
265
266 yPosTubsAux[w] = yPosTubsPlate[ee];
267
268 rotAngleTubsAuxX[w] = rotAngleX[ss];
269
270 rotAngleTubsAuxY[w] = rotAngleY[ee];
271
272 rotAngleTubsAuxZ[w] = rotAngleZ[ss];
273
274 }
275
276 GENFUNCTION fTubsRotX = ArrayFunction( rotAngleTubsAuxX, rotAngleTubsAuxX + nAllpos );
277 GENFUNCTION fTubsTrlX = ArrayFunction( xPosTubsAux, xPosTubsAux + nAllpos );
278 GENFUNCTION fTubsRotY = ArrayFunction( rotAngleTubsAuxY, rotAngleTubsAuxY + nAllpos );
279 GENFUNCTION fTubsTrlY = ArrayFunction( yPosTubsAux, yPosTubsAux + nAllpos );
280 GENFUNCTION fTubsRotZ = ArrayFunction( rotAngleTubsAuxZ, rotAngleTubsAuxZ + nAllpos );
281 GENFUNCTION fTubsTrlZ = ArrayFunction( zPosTubsAux, zPosTubsAux + nAllpos );
282
283 TRANSFUNCTION XFTubsPlate = Pow( HepTranslateX3D(1.0), fTubsTrlX ) *
284 Pow( HepTranslateY3D(1.0), fTubsTrlY ) *
285 Pow( HepTranslateZ3D(1.0), fTubsTrlZ ) *
286 Pow( HepRotateX3D(1.0), fTubsRotX ) *
287 Pow( HepRotateY3D(1.0), fTubsRotY ) *
288 Pow( HepRotateZ3D(1.0), fTubsRotZ );
289
290 GeoSerialTransformer* sxTubsPlate = new GeoSerialTransformer( pTubsPlate,
291 &XFTubsPlate,
292 nAllpos );
293
294
295 container->add(sxTubsPlate);
296 }
297
298 n = n + NumVol;
299 NumVol = 0;
300
301 }
302 }
303
304 std::string SaddleTubsBuilder::getMaterial( std::string materialName )
305 {
306 MsgStream log(Athena::getMessageSvc(), "MuonGeoModel");
307 if ( materialName == "Alum" )
308 {
309 return "std::Aluminium";
310 }
311 else if ( materialName == "Iron" )
312 {
313 return "std::Iron";
314 }
315 else if ( materialName == "Fe50" || materialName == "Al67" )
316 {
317 return "toro::" + materialName;
318 }
319 else
320 {
321 log << " SaddleTubsBuilder::getMaterial: material " << materialName
322 << " not defined! "
323 << " Take Aluminium instead."
324 << endreq;
325 return "std::Aluminium";
326 }
327 }
328
329 }
330
| 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.
|
|