001
002 #include "MuonGeoModel/SaddleBoxesBuilder.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 SaddleBoxesBuilder::SaddleBoxesBuilder( 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
071
072 m_Saddlebovp = pRDBAccess->getRecordset("SADDLEBOVP", geoTag, geoNode);
073 m_Saddlebovs = pRDBAccess->getRecordset("SADDLEBOVS", geoTag, geoNode);
074 m_Saddlebovn = pRDBAccess->getRecordset("SADDLEBOVN", geoTag, geoNode);
075
076
077
078
079
080
081
082 m_Saddle = pRDBAccess->getRecordset("SADDLE", geoTag, geoNode);
083 if (m_Saddle->size()*m_Saddlebovp->size()*m_Saddlebovs->size()*m_Saddlebovn->size() == 0)
084 _unavailableData = true;
085
086
087 std::string Iron = "Iron";
088
089 std::string Aluminium = "Alum";
090
091 MsgStream log( Athena::getMessageSvc(), "MuGM:SaddleBoxesBuilder" );
092 if (!_unavailableData) log << MSG::INFO << "All data fetched with tag <" << geoTag << ">" << endreq;
093 else log << MSG::INFO << "No data found with tag <" << geoTag << ">" << endreq;
094 }
095
096 void SaddleBoxesBuilder::buildSaddleBoxes( GeoPhysVol* container )
097 {
098
099
100 const StoredMaterialManager* theMaterialManager;
101 if ( StatusCode::SUCCESS != m_pDetStore->retrieve( theMaterialManager, "MATERIALS" ) )
102 {
103 return;
104 }
105 int n = 0;
106 int f = 0;
107 int g = 0;
108
109
110 int Numboxes = (int)(*m_Saddle)[0]->getFloat("SADL_NUMBOXES");
111
112 double Xposb[100];
113 double Yposb[100];
114 double Zposb[100];
115 double Xposgl[100];
116 double Yposgl[100];
117 double Zposgl[100];
118 double Rotx[100];
119 double Roty[100];
120 double Rotz[100];
121 for (int k = 0; k < Numboxes; k++)
122 {
123
124 int NumVol = (int)(*m_Saddlebovn)[k]->getFloat("NUMVOL");
125 int Numembo = (int)(*m_Saddlebovn)[k]->getFloat("NUMEMBO");
126 int Numemtu = (int)(*m_Saddlebovn)[k]->getFloat("NUMEMTU");
127
128 int SymX = (int)(*m_Saddlebovn)[k]->getFloat("SYMX");
129 int SymY = (int)(*m_Saddlebovn)[k]->getFloat("SYMY");
130 int SymZ = (int)(*m_Saddlebovn)[k]->getFloat("SYMZ");
131
132
133 float Dx = (*m_Saddlebovs)[k]->getFloat("DX") * mm;
134 float Dy = (*m_Saddlebovs)[k]->getFloat("DY") * mm;
135 float Dz = (*m_Saddlebovs)[k]->getFloat("DZ") * mm;
136
137
138
139
140 const std::string saddleMaterial = getMaterial( "Iron" );
141
142
143
144
145
146
147
148
149
150
151
152
153
154 GeoBox* Box = new GeoBox(Dx/2 , Dy/2, Dz/2);
155
156
157 const GeoShape* sBox = &( *Box );
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
185
186 f = f + Numemtu;
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210 g = g + Numembo;
211
212 for (int j = n; j < NumVol + n; j++)
213 {
214
215 Zposgl[j] = (*m_Saddlebovp)[j]->getFloat("ZPOSGL") * mm;
216 Xposgl[j] = (*m_Saddlebovp)[j]->getFloat("XPOSGL") * mm;
217 Yposgl[j] = (*m_Saddlebovp)[j]->getFloat("YPOSGL") * mm;
218 Zposb[j] = (*m_Saddlebovp)[j]->getFloat("ZPOSB") * mm;
219 Xposb[j] = (*m_Saddlebovp)[j]->getFloat("XPOSB") * mm;
220 Yposb[j] = (*m_Saddlebovp)[j]->getFloat("YPOSB") * mm;
221 Rotx[j] = (*m_Saddlebovp)[j]->getFloat("ROTX") * deg;
222 Roty[j] = (*m_Saddlebovp)[j]->getFloat("ROTY") * deg;
223 Rotz[j] = (*m_Saddlebovp)[j]->getFloat("ROTZ") * deg;
224
225
226
227 HepTransform3D trlBox = HepTranslate3D(Xposb[j], Yposb[j], 0.) * HepRotateY3D(Roty[j])
228 * HepRotateZ3D(Rotz[j]) * HepRotateX3D(Rotx[j]);
229
230 const GeoShape& posBoxPlate = ( *sBox << trlBox );
231
232 GeoLogVol* lBoxPlate = new GeoLogVol( "SaddleBoxes",
233 &posBoxPlate,
234 theMaterialManager->getMaterial(saddleMaterial) );
235 GeoPhysVol* pBoxPlate = new GeoPhysVol(lBoxPlate);
236
237
238
239
240
241 int nXpos = SymX + 1;
242 int nYpos = SymY + 1;
243 int nZpos = SymZ + 1;
244
245
246 double rotAngleX[2] = { 0, M_PI };
247 double xPosBoxPlate[2] = {Xposgl[j], -Xposgl[j]};
248 double rotAngleY[2] = { 0, M_PI };
249 double yPosBoxPlate[2] = {Yposgl[j], -Yposgl[j]};
250 double rotAngleZ[2] = { 0, M_PI }; double zPosBoxPlate[2] = {(Zposgl[j] + Zposb[j]), -(Zposgl[j] + Zposb[j])};
251
252 const int nAllpos = nXpos * nYpos * nZpos;
253
254
255
256 double zPosAux[100], xPosAux[100], yPosAux[100], rotAngleAuxX[100], rotAngleAuxY[100], rotAngleAuxZ[100];
257
258 for ( int w = 0; w < nAllpos; w++ )
259 {
260
261 int ww = w % (nAllpos / nZpos),
262 ss = w / (nAllpos / nXpos),
263 ee = w / (nAllpos / nYpos);
264
265
266
267
268 zPosAux[w] = zPosBoxPlate[ww];
269
270 xPosAux[w] = xPosBoxPlate[ss];
271
272 yPosAux[w] = yPosBoxPlate[ee];
273
274 rotAngleAuxX[w] = rotAngleX[ss];
275
276 rotAngleAuxY[w] = rotAngleY[ee];
277
278 rotAngleAuxZ[w] = rotAngleZ[ss];
279
280 }
281
282 GENFUNCTION fRotX = ArrayFunction( rotAngleAuxX, rotAngleAuxX + nAllpos );
283 GENFUNCTION fTrlX = ArrayFunction( xPosAux, xPosAux + nAllpos );
284 GENFUNCTION fRotY = ArrayFunction( rotAngleAuxY, rotAngleAuxY );
285 GENFUNCTION fTrlY = ArrayFunction( yPosAux, yPosAux + nAllpos );
286 GENFUNCTION fRotZ = ArrayFunction( rotAngleAuxZ, rotAngleAuxZ + nAllpos );
287 GENFUNCTION fTrlZ = ArrayFunction( zPosAux, zPosAux + nAllpos );
288
289 TRANSFUNCTION XFBoxPlate = Pow( HepTranslateX3D(1.0), fTrlX ) *
290 Pow( HepTranslateY3D(1.0), fTrlY ) *
291 Pow( HepTranslateZ3D(1.0), fTrlZ ) *
292 Pow( HepRotateX3D(1.0), fRotX ) *
293 Pow( HepRotateY3D(1.0), fRotY ) *
294 Pow( HepRotateZ3D(1.0), fRotZ );
295
296
297 GeoSerialTransformer* sxBoxPlate = new GeoSerialTransformer( pBoxPlate,
298 &XFBoxPlate,
299 nAllpos );
300
301
302 container->add(sxBoxPlate);
303
304 }
305
306 n = n + NumVol;
307 NumVol = 0;
308
309 }
310 }
311
312 std::string SaddleBoxesBuilder::getMaterial( std::string materialName )
313 {
314 MsgStream log(Athena::getMessageSvc(), "MuonGeoModel");
315 if ( materialName == "Alum" )
316 {
317 return "std::Aluminium";
318 }
319 else if ( materialName == "Iron" )
320 {
321 return "std::Iron";
322 }
323 else if ( materialName == "Fe50" || materialName == "Al67" )
324 {
325 return "toro::" + materialName;
326 }
327 else
328 {
329 log << " SaddleBoxesBuilder::getMaterial: material " << materialName
330 << " not defined! "
331 << " Take Aluminium instead."
332 << endreq;
333 return "std::Aluminium";
334 }
335 }
336
337 }
338
| 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.
|
|