Report problems to ATLAS LXR Team (with time and IP address indicated)

The LXR Cross Referencer

source navigation ]
diff markup ]
identifier search ]
general search ]
 
 
Architecture: linux ]
Version: head ] [ nightly ] [ GaudiDev ]
  Links to LXR source navigation pages for stable releases [ 12.*.* ]   [ 13.*.* ]   [ 14.*.* ]   [ 15.*.* ] 

001 #include "MuonGeoModel/EndCapToroidBuilderRDB.h"
002 #include "AthenaKernel/getMessageSvc.h"
003 
004 #include "RDBAccessSvc/IRDBRecord.h"
005 #include "RDBAccessSvc/IRDBRecordset.h"
006 #include "RDBAccessSvc/IRDBAccessSvc.h"
007 
008 #include "MuonGeoModel/ArrayFunction.h"
009 
010 #include "GeoModelKernel/GeoBox.h"
011 #include "GeoModelKernel/GeoTube.h"
012 #include "GeoModelKernel/GeoPcon.h"
013 #include "GeoModelKernel/GeoTrd.h"
014 #include "GeoModelKernel/GeoTrap.h"
015 #include "GeoModelKernel/GeoPara.h"
016 #include "GeoModelKernel/GeoPgon.h"
017 #include "GeoModelKernel/GeoMaterial.h"
018 #include "GeoModelKernel/GeoLogVol.h"
019 #include "GeoModelKernel/GeoPhysVol.h"
020 #include "GeoModelKernel/GeoFullPhysVol.h"
021 #include "GeoModelKernel/GeoTransform.h"
022 #include "GeoModelKernel/GeoAlignableTransform.h"
023 #include "GeoModelKernel/GeoNameTag.h"
024 #include "GeoModelKernel/GeoShapeShift.h"
025 #include "GeoModelKernel/GeoShapeUnion.h"
026 #include "GeoModelKernel/GeoShapeSubtraction.h"
027 #include "GeoModelKernel/GeoSerialTransformer.h" 
028 #include "GeoModelKernel/GeoShapeIntersection.h"
029 #include "GeoModelKernel/GeoIdentifierTag.h"
030 #include "GeoModelSvc/StoredMaterialManager.h"
031 
032 #include "StoreGate/StoreGateSvc.h"
033 #include "CLHEP/GenericFunctions/Variable.hh"
034 
035 #include <stdexcept>
036 #include <vector>
037 #include <iomanip>
038 
039 #include <sstream>
040 typedef std::stringstream  my_sstream;
041 typedef std::ostringstream my_osstream;
042 
043 using namespace Genfun;
044 using namespace GeoXF;
045 
046 namespace MuonGM {
047 EndCapToroidBuilderRDB::EndCapToroidBuilderRDB( StoreGateSvc  *pDetStore,
048                                     IRDBAccessSvc *pRDBAccess, 
049                                     std::string    geoTag,
050                                     std::string    geoNode )    :
051     m_pRDBAccess(pRDBAccess), 
052     m_pDetStore (pDetStore)
053 {
054     //   std::cout<<" EndCapToroidBuilderRDB constructor "<<std::endl;
055    
056   MsgStream log( Athena::getMessageSvc(), "MuGM:EndCapToroBuildRDB" );
057   log  <<  MSG::INFO  <<  "Fetching data with tag <"  <<  geoTag <<  ">"  <<  endreq;
058   
059   m_Abrt = pRDBAccess->getRecordset("ABRT", geoTag, geoNode);
060   if (m_Abrt->size() == 0) {
061       log<<MSG::WARNING<<"Table ABRT not found in tag <"  <<  geoTag <<  ">"  <<" reading table ABRT-00" <<endreq;
062       m_Abrt = pRDBAccess->getRecordset("ABRT","ABRT-00");
063   }
064   m_Aect = pRDBAccess->getRecordset("AECT", geoTag, geoNode);
065   if (m_Aect->size() == 0) {
066       log<<MSG::WARNING<<"Table ABRT not found in tag <"  <<  geoTag <<  ">"  <<" reading table AECT-00" <<endreq;
067       m_Aect = pRDBAccess->getRecordset("AECT","AECT-00");
068   }
069   m_Feet = pRDBAccess->getRecordset("FEET", geoTag, geoNode);
070   if (m_Feet->size() == 0) {
071       log<<MSG::WARNING<<"Table FEET not found in tag <"  <<  geoTag <<  ">"  <<" reading table FEET-00" <<endreq;
072       m_Feet = pRDBAccess->getRecordset("FEET","FEET-00");
073   }
074   m_Rail = pRDBAccess->getRecordset("RAIL", geoTag, geoNode);
075   if (m_Rail->size() == 0) {
076       log<<MSG::WARNING<<"Table RAIL not found in tag <"  <<  geoTag <<  ">"  <<" reading table RAIL-00" <<endreq;
077       m_Rail = pRDBAccess->getRecordset("RAIL","RAIL-00");
078   }
079   m_Ecst = pRDBAccess->getRecordset("ECST", geoTag, geoNode);
080   if (m_Ecst->size() == 0) {
081       log<<MSG::WARNING<<"Table ECST not found in tag <"  <<  geoTag <<  ">"  <<" reading table ECST-00" <<endreq;
082       m_Ecst = pRDBAccess->getRecordset("ECST","ECST-00");
083   }
084 
085    std::string Iron = "Iron";
086    std::string Aluminium = "Aluminium";
087 
088 
089 }
090 
091  void EndCapToroidBuilderRDB::buildECTVacuumVessel( GeoPhysVol* container ) 
092 {
093   //------------------------------------------------------------------------------------------
094   //  Builds ECT Vacuum Vessel (end-plates, wall segments, staytubes)
095   //------------------------------------------------------------------------------------------
096 
097   const StoredMaterialManager*  theMaterialManager;
098   if ( StatusCode::SUCCESS != m_pDetStore->retrieve( theMaterialManager, "MATERIALS" ) ) 
099   {
100     return;
101   } 
102 
103    const double zMinECTVessel           = (*m_Aect)[0]->getFloat("CRYOZMIN") * mm;                
104    const double zDeltaECTVessel         = (*m_Aect)[0]->getFloat("CRYOZEXT") * mm;                
105    const double rMinECTVessel           = (*m_Aect)[0]->getFloat("CRYOR0")   * mm;                
106    const double deltaYToRailECTVessel   = (*m_Aect)[0]->getFloat("CRYOFLTY") * mm;                
107    const double outerThicknessECTVessel = (*m_Aect)[0]->getFloat("CRYOTHI3") * mm;                
108    const double innerThicknessECTVessel = (*m_Aect)[0]->getFloat("CRYOTHI2") * mm;                
109    const double zThicknessECTVessel     = (*m_Aect)[0]->getFloat("CRYOTHI1") * mm;                
110    const double rDistInnerCastECTVessel = (*m_Aect)[0]->getFloat("CRYOT2")   * mm;                
111    const double rDistOuterCastECTVessel = (*m_Aect)[0]->getFloat("CRYOT1")   * mm;                
112    const double widthInnerCastECTVessel = (*m_Aect)[0]->getFloat("CRYOS2")   * mm;                
113    const double widthOuterCastECTVessel = (*m_Aect)[0]->getFloat("CRYOS1")   * mm;                
114    const double rDistStaytubeECTVessel  = (*m_Aect)[0]->getFloat("CRYOTTU0") * mm;                
115    const double rInStaytubeECTVessel    = (*m_Aect)[0]->getFloat("CRYORTU0") * mm;                
116    const double rOutStaytubeECTVessel   = (*m_Aect)[0]->getFloat("CRYORTU1") * mm;                
117    const double angleStaytubeECTVessel  = (*m_Aect)[0]->getFloat("CRYODPHT")   * deg;             
118    const double radiusHoleECTVessel     = (*m_Aect)[0]->getFloat("CRYORTU1") * mm;                
119    // const double lengthVertexCutECTVessel= (*m_Aect)[0]->getFloat("CRYOEDGE") * mm;             
120                                                                               //
121    const std::string vesselMaterial = getMaterial(" Aluminium "); 
122 //----------------------------------------------------------------------------//
123   
124   
125   const double phi0    = M_PI/8;
126   const double cosPhi0 = cos(phi0);
127   //const double sinPhi0 = sin(phi0);
128   const double tanPhi0 = tan(phi0);
129   
130   // auxiliary arrays to store phi values, z positions for all volumes to be replicated 
131   const int nPhiSectors = 8;
132   const int nPosMax     = 4;
133   double phiAux[ nPhiSectors * nPosMax ],  posAux[ nPhiSectors * nPosMax ];
134 
135   
136   // Vacuum Vessel properties 
137   const double zMin              = zMinECTVessel;
138   const double zMax              = zMinECTVessel + zDeltaECTVessel;
139   const double rMin              = rMinECTVessel;
140   const double deltaZ            = zMax - zMin;
141   const double zMean             = 0.5 * ( zMin + zMax );
142   const double deltaYToRail      = deltaYToRailECTVessel;
143   const double thicknessEndplate = zThicknessECTVessel;
144   const double rOuterCast        = rDistOuterCastECTVessel;
145   const double rInnerCast        = rDistInnerCastECTVessel;
146   const double widthOuterCast    = widthOuterCastECTVessel;
147   const double widthInnerCast    = widthInnerCastECTVessel;
148   const double rStaytubeHole     = radiusHoleECTVessel;
149   const double distStaytube      = rDistStaytubeECTVessel;
150   const double angleStaytube     = phi0 + angleStaytubeECTVessel;
151   const double rInStaytube       = rInStaytubeECTVessel;
152   const double rOutStaytube      = rOutStaytubeECTVessel;
153   const double thicknessWall     = outerThicknessECTVessel;
154   const double thicknessCentTube = innerThicknessECTVessel;
155   //  const double lengthVertCut         = lengthVertexCutECTVessel;
156 
157   // Calculate angle (=alpha) between top and side plates of outer castellation
158   double ll1   = widthOuterCast/2;
159   double ll2   = rOuterCast - rInnerCast/cosPhi0;
160   double l1    = sqrt( ll1*ll1 + ll2*ll2 );
161   double l2    = rInnerCast * tanPhi0 -  widthInnerCast/2;
162   double beta1 = atan( ll1/ll2 );
163   double beta2 = M_PI/2 - beta1;
164   double beta3 = beta2 + phi0;
165   double l3    = sqrt( l1 * l1  +  l2 * l2  -  2 * l1 * l2 * cos(beta3) );  // outside length of 
166                                                                             // side plate
167   const double alpha = beta2 + asin( sin(beta3) * l2/l3 );
168 
169   //------------------------------------------------------------------------------------------
170   //  Build endplate standard segments
171   //  There are two segments (where the ECT rests on the rails) which have an extra 
172   //  horizontal cut-out and have to be treated separately (see below) 
173   //------------------------------------------------------------------------------------------
174 
175   //----------------------------------------------------------------------------------------
176   // start from octogonal segment (opening angle = 45 deg)
177   GeoPgon* sEndplatePgon = new GeoPgon( -phi0, 2 * phi0, 1 );
178   sEndplatePgon->addPlane( -thicknessEndplate/2, rMin/2, rOuterCast/cosPhi0 );
179   sEndplatePgon->addPlane(  thicknessEndplate/2, rMin/2, rOuterCast/cosPhi0 );
180 
181   // empty trapezoid to cut out the space between outer castellations
182   double pDzOuterTrap  = rOuterCast/cosPhi0 - rInnerCast;   
183   double pDy           = deltaZ/2;
184   double pDx3OuterTrap = widthInnerCast/2;
185   double pDx1OuterTrap = pDx3OuterTrap + 2 * pDzOuterTrap * tan( alpha + phi0 - M_PI/2 );
186   
187   GeoTrd* sEmptyOuterTrap = new GeoTrd( pDx1OuterTrap, pDx3OuterTrap, pDy, pDy, pDzOuterTrap );
188 
189   // empty tube to cut out the central tube
190   GeoTube* sEmptyCentTube = new GeoTube( 0, rMin, thicknessEndplate ); 
191 
192   // tube to cut out the staytube
193   GeoTube* sEmptyStaytube = new GeoTube( 0, rStaytubeHole, thicknessEndplate );
194   
195   // box to cut out vetex of outer castellation
196 //  GeoBox* sEmptyBoxOutCast = new GeoBox( lengthVertCut/2, lengthVertCut, deltaZ/2 );
197   
198 
199   //----------------------------------------------------------------------------------------
200   // cut out trapezoids, central tube, and staytube hole
201   
202   // trapezoid positioning wrt. endplate segment (trapezoid axes don't coincide with polygon ones)
203   double xPosTrap = rOuterCast;
204   double yPosTrap = rOuterCast * tanPhi0;
205 
206   HepTransform3D xfLeftTrap  = HepTranslate3D( xPosTrap,  yPosTrap, 0 ) * 
207                                HepRotateZ3D(  phi0 - M_PI/2 ) * HepRotateX3D( M_PI/2 );
208   HepTransform3D xfRightTrap = HepTranslate3D( xPosTrap, -yPosTrap, 0 ) * 
209                                HepRotateZ3D( -phi0 - M_PI/2 ) * HepRotateX3D( M_PI/2 );                               
210    
211   // staytube positioning wrt. endplate segment
212   HepTransform3D xfStaytubeHole = HepTranslate3D( distStaytube * cos(angleStaytube),
213                                                   distStaytube * sin(angleStaytube),
214                                                   0 );
215   // empty box position wrt. endplate segment
216 //  HepTransform3D xfLeftEmptyBoxOutCast = HepTranslate3D( rOuterCast, widthOuterCast/2, 0 ) * HepRotateZ3D( M_PI/4 );
217   
218 //  HepTransform3D xfRightEmptyBoxOutCast = HepTranslate3D( rOuterCast, -widthOuterCast/2, 0 ) * HepRotateZ3D( -M_PI/4 );
219 
220                                 
221   const GeoShape& sEndplateStdSegment = sEndplatePgon->subtract( (*sEmptyStaytube)  << xfStaytubeHole ).
222                                                        subtract(  *sEmptyCentTube ).
223 //                                                     subtract( (*sEmptyBoxOutCast ) << xfLeftEmptyBoxOutCast ).
224 //                                                     subtract( (*sEmptyBoxOutCast ) << xfRightEmptyBoxOutCast ).
225                                                        subtract( (*sEmptyOuterTrap) << xfLeftTrap ).
226                                                        subtract( (*sEmptyOuterTrap) << xfRightTrap );
227 
228   GeoLogVol*  lEndplateStdSegment = new GeoLogVol( "ECTEndplateStdSegment", 
229                                                    &sEndplateStdSegment, 
230                                                    theMaterialManager->getMaterial(vesselMaterial) );
231   GeoPhysVol* pEndplateStdSegment = new GeoPhysVol(lEndplateStdSegment);
232 
233 
234   //------------------------------------------------------------------------------------------
235   // Replicate and position
236   
237   // array of phi values
238   const int nStdSectors = 6;
239   double phiStdSector[nStdSectors];
240   for ( int i = 0; i < nStdSectors - 1; i++ )  phiStdSector[i] = 2 * i * phi0;  
241   phiStdSector[ nStdSectors - 1 ] = 12 * phi0; 
242   
243   // array of z positions
244   const int nZPosEndplate = 4;
245   double zPosEndplate[nZPosEndplate] = { -zMean - deltaZ/2 + thicknessEndplate/2, 
246                                          -zMean + deltaZ/2 - thicknessEndplate/2,
247                                           zMean - deltaZ/2 + thicknessEndplate/2,
248                                           zMean + deltaZ/2 - thicknessEndplate/2 };
249   // fill auxiliary arrays
250   for ( int i = 0; i < nStdSectors * nZPosEndplate; i++ )  
251   {
252      int ii = i % nStdSectors, 
253          jj = i / nStdSectors;
254      phiAux[i] = phiStdSector[ii]; 
255      posAux[i] = zPosEndplate[jj];
256   }
257 
258   GENFUNCTION fRotStd = ArrayFunction( phiAux, phiAux + nStdSectors * nZPosEndplate ); 
259   GENFUNCTION fTrlStd = ArrayFunction( posAux, posAux + nStdSectors * nZPosEndplate ); 
260   
261   TRANSFUNCTION XFEndplateStdSegment = Pow( HepRotateZ3D(1.0), fRotStd ) * Pow( HepTranslateZ3D(1.0), fTrlStd ); 
262 
263   GeoSerialTransformer* sxEndplateStdSegment = new GeoSerialTransformer( pEndplateStdSegment, 
264                                                                          &XFEndplateStdSegment, 
265                                                                          nStdSectors * nZPosEndplate );
266   container->add(sxEndplateStdSegment);
267   
268   //------------------------------------------------------------------------------------------
269   //  Build endplate segments resting on rails ("segment6", "segment8"), which have extra 
270   //  horizontal cut-outs wrt. standard segments
271   //------------------------------------------------------------------------------------------
272 
273   // box to cut out the extra space for the rail support 
274   // (will be used later also for the wall segments)
275   double cutLengthOut = widthOuterCast/2 - sqrt(2) * deltaYToRail + rOuterCast; 
276   double dXRailBox = cutLengthOut / sqrt(2);
277   double dYRailBox = widthOuterCast;     // some 'large enough' value
278   double dZRailBox = deltaZ/2;           // some 'large enough' value
279   
280   GeoBox* sEmptyRailBox = new GeoBox( dXRailBox, dYRailBox, dZRailBox );
281 
282   // box positioning wrt. endplate segment
283   HepTransform3D xfRailBox6 = HepTranslate3D( rOuterCast,  widthOuterCast/2, 0 ) * HepRotateZ3D(  M_PI/4 );
284   HepTransform3D xfRailBox8 = HepTranslate3D( rOuterCast, -widthOuterCast/2, 0 ) * HepRotateZ3D( -M_PI/4 );
285   
286   
287   //----------------------------------------------------------------------------------------
288   // cut out trapezoids, central tube, staytube hole, and space for rail support 
289   const GeoShape& sEndplateRailSegment6 = sEndplatePgon->subtract( (*sEmptyStaytube)  << xfStaytubeHole ). 
290                                                          subtract(  *sEmptyCentTube ).
291                                                          subtract( (*sEmptyOuterTrap) << xfLeftTrap ).
292                                                          subtract( (*sEmptyOuterTrap) << xfRightTrap ).
293                                                          subtract( (*sEmptyRailBox)   << xfRailBox6 );
294   const GeoShape& sEndplateRailSegment8 = sEndplatePgon->subtract( (*sEmptyStaytube)  << xfStaytubeHole ). 
295                                                          subtract(  *sEmptyCentTube ).
296                                                          subtract( (*sEmptyOuterTrap) << xfLeftTrap ).
297                                                          subtract( (*sEmptyOuterTrap) << xfRightTrap ).
298                                                          subtract( (*sEmptyRailBox)   << xfRailBox8 );
299 
300   GeoLogVol*  lEndplateRailSegment6 = new GeoLogVol( "ECTEndplateRailSegment6", 
301                                                      &sEndplateRailSegment6, 
302                                                      theMaterialManager->getMaterial(vesselMaterial) );
303   GeoLogVol*  lEndplateRailSegment8 = new GeoLogVol( "ECTEndplateRailSegment8", 
304                                                      &sEndplateRailSegment8, 
305                                                      theMaterialManager->getMaterial(vesselMaterial) );
306 
307   GeoPhysVol* pEndplateRailSegment6 = new GeoPhysVol(lEndplateRailSegment6);
308   GeoPhysVol* pEndplateRailSegment8 = new GeoPhysVol(lEndplateRailSegment8);
309 
310 
311   //------------------------------------------------------------------------------------------
312   // Replicate and position
313   GENFUNCTION fTrlRail = ArrayFunction( zPosEndplate, zPosEndplate + nZPosEndplate ); 
314   
315   TRANSFUNCTION XFEndplateRailSegment6 = HepRotateZ3D( 10 * phi0 ) * Pow( HepTranslateZ3D(1.0), fTrlRail ); 
316   TRANSFUNCTION XFEndplateRailSegment8 = HepRotateZ3D( 14 * phi0 ) * Pow( HepTranslateZ3D(1.0), fTrlRail ); 
317 
318   GeoSerialTransformer* sxEndplateRailSegment6 = new GeoSerialTransformer( pEndplateRailSegment6, 
319                                                                            &XFEndplateRailSegment6, 
320                                                                            nZPosEndplate );
321   GeoSerialTransformer* sxEndplateRailSegment8 = new GeoSerialTransformer( pEndplateRailSegment8, 
322                                                                            &XFEndplateRailSegment8, 
323                                                                            nZPosEndplate );
324   container->add(sxEndplateRailSegment6);
325   container->add(sxEndplateRailSegment8);
326 
327   //------------------------------------------------------------------------------------------
328   //  Build wall standard segments
329   //  There are two segments (where the ECT rests on the rails) which have an extra 
330   //  horizontal cut-out and have to be treated separately (see below) 
331   //----------------------------------------------------------------------------------------
332   // start from equilateral triangular prism (opening angle = 45 deg)
333   GeoPgon* sWallPgon = new GeoPgon( -phi0, 2 * phi0, 1 );
334   sWallPgon->addPlane( -deltaZ/2 + thicknessEndplate, rMin, rOuterCast/cosPhi0 );
335   sWallPgon->addPlane(  deltaZ/2 - thicknessEndplate, rMin, rOuterCast/cosPhi0 );
336 
337   // quarter of 'large enough' octogonal prism to cut out most of the inner volume 
338   GeoPgon* sEmptyPgon = new GeoPgon( -2 * phi0, 4 * phi0, 2 );
339   sEmptyPgon->addPlane( -deltaZ/2, 0, ( rInnerCast - thicknessWall )/cosPhi0 );
340   sEmptyPgon->addPlane(  deltaZ/2, 0, ( rInnerCast - thicknessWall )/cosPhi0 );
341 
342   // trapezoid to cut out the remaining inner volume (= inside of outer castellations)
343   double gamma         = ( M_PI - alpha )/2;
344   double pDx1InnerTrap = widthOuterCast/2 - thicknessWall * tan(gamma); 
345   double pDzInnerTrap  = rOuterCast/4;                                   // some 'large enough' value  
346   double pDx3InnerTrap = pDx1InnerTrap + 2 * pDzInnerTrap * tan( alpha - M_PI/2 ); 
347 
348   GeoTrd* sEmptyInnerTrap = new GeoTrd( pDx1InnerTrap, pDx3InnerTrap, pDy, pDy, pDzInnerTrap );
349 
350 
351   //----------------------------------------------------------------------------------------
352   // cut out inner prism and trapezoids
353   // - use sEmptyOuterTrap shape from above to cut out space between outer castellations
354 
355   // trapezoid positioning wrt. wall segment (trapezoid axes don't coincide with polygon ones)
356   HepTransform3D xfInnerTrap = HepTranslateX3D( rOuterCast - thicknessWall - pDzInnerTrap ) * 
357                                HepRotateZ3D( -M_PI/2 ) * HepRotateX3D( M_PI/2 );
358 
359   const GeoShape& sWallStdSegment = sWallPgon->subtract(  *sEmptyPgon ).
360                                                subtract( (*sEmptyOuterTrap) << xfLeftTrap ).
361                                                subtract( (*sEmptyOuterTrap) << xfRightTrap ).
362                                                subtract( (*sEmptyInnerTrap) << xfInnerTrap );
363 
364   GeoLogVol*  lWallStdSegment = new GeoLogVol( "ECTWallStdSegment", 
365                                                &sWallStdSegment, 
366                                                theMaterialManager->getMaterial(vesselMaterial) );
367   GeoPhysVol* pWallStdSegment = new GeoPhysVol(lWallStdSegment);
368 
369 
370   //------------------------------------------------------------------------------------------
371   // Replicate and position
372   
373   // array of z positions
374   const int nZPosWall = 2;
375   double zPosWall[nZPosWall] = { -zMean, zMean };
376   
377   // fill auxiliary arrays
378   for ( int i = 0; i < nStdSectors * nZPosWall; i++ )  
379   {
380      int ii = i % nStdSectors, 
381          jj = i / nStdSectors;
382      phiAux[i] = phiStdSector[ii];
383      posAux[i] = zPosWall[jj];    
384   }
385 
386   GENFUNCTION fRotWallStd = ArrayFunction( phiAux, phiAux + nStdSectors * nZPosWall ); 
387   GENFUNCTION fTrlWallStd = ArrayFunction( posAux, posAux + nStdSectors * nZPosWall ); 
388   
389   TRANSFUNCTION XFWallStdSegment = Pow( HepRotateZ3D(1.0), fRotWallStd ) * Pow( HepTranslateZ3D(1.0), fTrlWallStd ); 
390 
391   GeoSerialTransformer* sxWallStdSegment = new GeoSerialTransformer( pWallStdSegment, 
392                                                                      &XFWallStdSegment, 
393                                                                      nStdSectors * nZPosWall );
394   container->add(sxWallStdSegment);
395 
396   //------------------------------------------------------------------------------------------
397   //  Build wall segments resting on rails ("segment6", "segment8"), which have extra 
398   //  horizontal cut-outs wrt. standard segments
399   //------------------------------------------------------------------------------------------
400   // cut edge from empty inner trapezoid by means of above sEmptyRailBox 
401   
402   // box positioning wrt. empty inner trapezoid (box axes don't coincide with trapezoid ones) 
403   // (positioning wrt. wall segment is the same as for endplates --> xfRailBox6 above)
404   double delta = thicknessEndplate * ( 1/cos(gamma) - 1 );
405   HepTransform3D shift          = HepTranslate3D( -delta * sin(gamma), 0 , -delta * cos(gamma) ); 
406   HepTransform3D xfInnerRailBox = shift * HepTranslate3D( -pDx1InnerTrap, 0, -pDzInnerTrap ) *
407                                   HepRotateY3D( -M_PI/4 ) * HepRotateX3D(  M_PI/2 );
408 
409   const GeoShape& sEmptyBevelledTrap = sEmptyInnerTrap->subtract( (*sEmptyRailBox) << xfInnerRailBox );
410 
411   //----------------------------------------------------------------------------------------
412   // cut out inner prism, outer trapezoids, and bevelled trapezoid from wall polygon segment
413   // - need only one 'master' shape (e.g. segment6; segment8 can be obtained via reflection) 
414   const GeoShape& sWallRailSegment = sWallPgon->subtract( (*sEmptyOuterTrap)   << xfLeftTrap ).
415                                                 subtract( (*sEmptyOuterTrap)   << xfRightTrap ).
416                                                 subtract( (*sEmptyRailBox)     << xfRailBox6 ).
417                                                 subtract(  *sEmptyPgon ).
418                                                 subtract(   sEmptyBevelledTrap << xfInnerTrap );
419 
420   GeoLogVol*  lWallRailSegment = new GeoLogVol( "ECTWallRailSegment", 
421                                                 &sWallRailSegment, 
422                                                 theMaterialManager->getMaterial(vesselMaterial) );
423   GeoPhysVol* pWallRailSegment = new GeoPhysVol(lWallRailSegment);
424 
425 
426   //------------------------------------------------------------------------------------------
427   // Replicate and position
428   GENFUNCTION fTrlWallRail = ArrayFunction( zPosWall, zPosWall + nZPosWall ); 
429   
430   TRANSFUNCTION XFWallRailSegment6 = HepRotateZ3D( 10 * phi0 ) * Pow( HepTranslateZ3D(1.0), fTrlWallRail ); 
431   TRANSFUNCTION XFWallRailSegment8 = HepRotateZ3D(  6 * phi0 ) * Pow( HepTranslateZ3D(1.0), fTrlWallRail ) * 
432                                      HepRotateY3D(M_PI); 
433 
434   GeoSerialTransformer* sxWallRailSegment6 = new GeoSerialTransformer( pWallRailSegment, 
435                                                                        &XFWallRailSegment6, 
436                                                                        nZPosWall );
437   GeoSerialTransformer* sxWallRailSegment8 = new GeoSerialTransformer( pWallRailSegment, 
438                                                                        &XFWallRailSegment8, 
439                                                                        nZPosWall );
440   container->add(sxWallRailSegment6);
441   container->add(sxWallRailSegment8);
442 
443   //------------------------------------------------------------------------------------------
444   //  Build central tube 
445   //------------------------------------------------------------------------------------------
446   
447   GeoTube* sCentTube = new GeoTube( rMin, rMin + thicknessCentTube, deltaZ/2 - thicknessEndplate );
448 
449   GeoLogVol*  lCentTube = new GeoLogVol( "ECTCentralTube", sCentTube, theMaterialManager->getMaterial(vesselMaterial) );
450   GeoPhysVol* pCentTube = new GeoPhysVol(lCentTube);
451 
452   //------------------------------------------------------------------------------------------
453   // Replicate and position  (same z position as for wall segments)
454   TRANSFUNCTION XFCentTube = Pow( HepTranslateZ3D(1.0), fTrlWallRail ); 
455 
456   GeoSerialTransformer* sxCentTube = new GeoSerialTransformer( pCentTube, &XFCentTube, nZPosWall );
457 
458   container->add(sxCentTube);
459   
460   //------------------------------------------------------------------------------------------
461   //  Build staytubes 
462   //------------------------------------------------------------------------------------------
463 
464   GeoTube* sStaytube = new GeoTube( rInStaytube, rOutStaytube, deltaZ/2 - thicknessEndplate );
465 
466   GeoLogVol*  lStaytube = new GeoLogVol( "ECTStaytube", sStaytube, theMaterialManager->getMaterial(vesselMaterial) );
467   GeoPhysVol* pStaytube = new GeoPhysVol(lStaytube);
468 
469   //------------------------------------------------------------------------------------------
470   // Replicate and position  (same z position as for wall segments)
471   
472   // fill auxiliary arrays
473   for ( int i = 0; i < nPhiSectors * nZPosWall; i++ )  
474   {
475      int ii = i % nPhiSectors, 
476          jj = i / nPhiSectors;
477      phiAux[i] = 2 * ii * phi0;
478      posAux[i] = zPosWall[jj]; 
479   }
480 
481   GENFUNCTION fRotStaytube = ArrayFunction( phiAux, phiAux + nPhiSectors * nZPosWall ); 
482   GENFUNCTION fTrlStaytube = ArrayFunction( posAux, posAux + nPhiSectors * nZPosWall ); 
483   
484   TRANSFUNCTION XFStaytube = Pow( HepRotateZ3D(1.0), fRotStaytube ) * 
485                              Pow( HepTranslateZ3D(1.0), fTrlStaytube ) * 
486                              xfStaytubeHole; 
487 
488   GeoSerialTransformer* sxStaytube = new GeoSerialTransformer( pStaytube, &XFStaytube, nPhiSectors * nZPosWall );
489 
490   container->add(sxStaytube);
491 
492 }
493 
494 
495  void EndCapToroidBuilderRDB::buildECTConductorBox( GeoPhysVol* container ) 
496 {
497   //------------------------------------------------------------------------------------------
498   //  Builds ECT Conductor and Coil Casing
499   //------------------------------------------------------------------------------------------
500 
501   const StoredMaterialManager*  theMaterialManager;
502   if ( StatusCode::SUCCESS != m_pDetStore->retrieve( theMaterialManager, "MATERIALS" ) ) 
503   {
504     return;
505   } 
506 
507    const double zMinECTVessel        = (*m_Aect)[0]->getFloat("CRYOZMIN") * mm;                
508    const double zDeltaECTVessel      = (*m_Aect)[0]->getFloat("CRYOZEXT") * mm; 
509    const double zMinECTCondBox       = (*m_Aect)[0]->getFloat("CNBXZMIN") * mm;                
510    const double zMaxECTCondBox       = (*m_Aect)[0]->getFloat("CNBXZMAX") * mm;                
511    const double rMinECTCondBox       = (*m_Aect)[0]->getFloat("CNBXTMIN") * mm;                
512    const double rMaxECTCondBox       = (*m_Aect)[0]->getFloat("CNBXTMAX") * mm;                
513    const double thicknessECTCondBox  = (*m_Aect)[0]->getFloat("CNBXTHIC") * mm;                
514    const double lCornerCutECTCondBox = (*m_Aect)[0]->getFloat("CNBXEDGE") * mm;                
515                                                                               //
516    const std::string condMaterial = getMaterial( "Aluminium" ); 
517 //----------------------------------------------------------------------------//
518   
519 
520   const double phi0 = M_PI/8;
521   
522   // Conductor Box properties 
523   const double deltaZ       = zMaxECTCondBox - zMinECTCondBox; 
524   const double distToCorner = lCornerCutECTCondBox; 
525   const double deltaR       = rMaxECTCondBox - rMinECTCondBox;
526   const double thickness    = thicknessECTCondBox;
527 
528   const double zMin         = zMinECTVessel;
529   const double zMax         = zMinECTVessel + zDeltaECTVessel; 
530   const double zMean        = (zMin + zMax)/2;                  //
531   // positioning variables
532 //  const double zMean = 0.5 * ( zMaxECTCondBox + zMinECTCondBox ); //v Saclay izpol'zuetsia (CryoXmin + CryoZmax)/2
533   const double rMean = 0.5 * ( rMaxECTCondBox + rMinECTCondBox );
534 
535 
536   //------------------------------------------------------------------------------------------
537   //  Build Conductor Box as a large box with bevelled corners 
538   //------------------------------------------------------------------------------------------
539 
540   // large box 
541   const GeoShape* sConductorBox = new GeoBox( deltaR/2, thickness/2, deltaZ/2 );
542 
543   // 'large enough' empty box to cut edges from large box
544   double lDiag = sqrt(2) * distToCorner;
545   GeoBox* sEmptyBox = new GeoBox( lDiag/2, thickness, lDiag ); 
546                                                                       
547 
548   //----------------------------------------------------------------------------------------
549   // cut away edges from large box
550 
551   // positioning of empty box centres wrt. large box centre
552   HepTransform3D trlEmptyBox[4] = { HepTranslate3D(  deltaR/2, 0, -deltaZ/2 ),
553                                     HepTranslate3D( -deltaR/2, 0, -deltaZ/2 ),
554                                     HepTranslate3D( -deltaR/2, 0,  deltaZ/2 ),
555                                     HepTranslate3D(  deltaR/2, 0,  deltaZ/2 ) };
556   for ( int i = 0; i < 4; i++ )
557   {
558      HepTransform3D xfEmptyBox = trlEmptyBox[i] * HepRotateY3D( ( 2*i + 1 ) * M_PI/4 );
559      sConductorBox = &( sConductorBox->subtract( (*sEmptyBox) << xfEmptyBox ) );
560   }
561 
562   GeoLogVol*  lConductorBox = new GeoLogVol( "ECTConductorBox", 
563                                              sConductorBox, 
564                                              theMaterialManager->getMaterial(condMaterial) );
565   GeoPhysVol* pConductorBox = new GeoPhysVol(lConductorBox);
566 
567 
568   //------------------------------------------------------------------------------------------
569   // Replicate and position
570 
571   // array of phi values
572   const int nPhiSectors = 8;
573   double phiVal[nPhiSectors];
574   for ( int i = 0; i < nPhiSectors; i++ )  phiVal[i] = 2 * i * phi0;  
575   
576   // array of z positions
577   const int nZPos = 2;
578   double zPos[nZPos] = { -zMean, zMean };
579     
580   // auxiliary arrays to store phi values, z positions for all volumes to be replicated 
581   double phiAux[ nPhiSectors * nZPos ],  posAux[ nPhiSectors * nZPos ];
582   for ( int i = 0; i < nPhiSectors * nZPos; i++ )  
583   {
584      int ii = i % nPhiSectors, 
585          jj = i / nPhiSectors;
586      phiAux[i] = phiVal[ii]; 
587      posAux[i] = zPos[jj];
588   }
589 
590   GENFUNCTION fRot = ArrayFunction( phiAux, phiAux + nPhiSectors * nZPos ); 
591   GENFUNCTION fTrl = ArrayFunction( posAux, posAux + nPhiSectors * nZPos ); 
592   
593   TRANSFUNCTION XFConductorBox = Pow( HepRotateZ3D(1.0), fRot ) * 
594                                  Pow( HepTranslateZ3D(1.0), fTrl ) * HepTranslateX3D(rMean); 
595   
596   GeoSerialTransformer* sxConductorBox = new GeoSerialTransformer( pConductorBox, 
597                                                                    &XFConductorBox, 
598                                                                    nPhiSectors * nZPos );
599   container->add(sxConductorBox);
600 
601 }
602 
603  void EndCapToroidBuilderRDB::buildECTKeystoneBox( GeoPhysVol* container ) 
604 {
605 
606   const StoredMaterialManager*  theMaterialManager;
607   if ( StatusCode::SUCCESS != m_pDetStore->retrieve( theMaterialManager, "MATERIALS" ) ) 
608   {
609     return;
610   } 
611 
612    const double tolerance = 0.1 * mm;
613 
614    const double zMinECTVessel         = (*m_Aect)[0]->getFloat("CRYOZMIN") * mm;  
615    const double zoffsetKeystone       = (*m_Aect)[0]->getFloat("SUPPLZOF") * mm;
616    const double zExtKeystone          = (*m_Aect)[0]->getFloat("SUPPLZEX") * mm;
617    const double zThicknessECTKeystone = (*m_Aect)[0]->getFloat("SUPPLTHZ") * mm;                   
618    const double rMinInnerECTKeystone  = (*m_Aect)[0]->getFloat("SUPPLTMI") * mm;
619    const double rThicknessECTKeystone = (*m_Aect)[0]->getFloat("SUPPLTHT") * mm;
620    const double rMinOuterECTKeystone  = (*m_Aect)[0]->getFloat("SUPPLTMA") * mm;
621    const double widthOuterECTKeystone   = (*m_Aect)[0]->getFloat("SUPPLATX_3") * mm;//2828.5 * mm;                   // etkb->widout!!! etogo u Saclay net!!!
622    const double widthBot                = (*m_Aect)[0]->getFloat("SUPPLATX_0") * mm;
623    const double radiusHoleECTKeystone   = (*m_Aect)[0]->getFloat("SUPPLRHO") * mm; 
624    const double rDistStaytubeECTVessel  = (*m_Aect)[0]->getFloat("CRYOTTU0") * mm;
625                                                                               //
626    const std::string keystoneMaterial = getMaterial( "Aluminium" );
627 //----------------------------------------------------------------------------//
628   
629 
630   const double phi0 = M_PI/8;
631   
632   // Keystone Box properties 
633   const double zMinECTKeystone = zMinECTVessel + zoffsetKeystone;
634   const double zMaxECTKeystone = zMinECTKeystone + zExtKeystone;
635   const double deltaZOut    = zMaxECTKeystone - zMinECTKeystone; 
636   const double deltaZIn     = deltaZOut - zThicknessECTKeystone; 
637   const double rMinIn       = rMinInnerECTKeystone; 
638   const double rMaxIn       = rMinInnerECTKeystone + rThicknessECTKeystone; 
639   const double rMinOut      = rMinOuterECTKeystone; 
640   const double rMaxOut      = rMinOuterECTKeystone + rThicknessECTKeystone; 
641   const double deltaROut    = rMaxOut - rMinIn; 
642   const double deltaRIn     = rMinOut - rMaxIn; 
643   const double thicknessTop = rMaxOut - rMinOut;
644   const double thicknessBot = rMaxIn  - rMinIn; 
645   const double widthTop     = widthOuterECTKeystone; 
646 //  const double widthBot     = widthTop - 2 * deltaROut * tan(phi0); 
647   const double holeRadius   = radiusHoleECTKeystone; 
648   const double rDistHole    = rDistStaytubeECTVessel;
649 
650   // positioning variables
651   const double zMean = 0.5 * ( zMaxECTKeystone + zMinECTKeystone ); 
652   const double rMean = 0.5 * ( rMaxOut +  rMinIn );
653 
654 
655   //------------------------------------------------------------------------------------------
656   //  Build Keystone Box as trapezoidal shape; 
657   //  inner empty space is cut out by a box, holes in the vertical plates by a tube 
658   //------------------------------------------------------------------------------------------
659 
660   // main (outer) trapezoid 
661   GeoTrd* sOuterTrap = new GeoTrd( widthTop/2 - tolerance, widthBot/2 - tolerance, deltaZOut/2, deltaZOut/2, deltaROut/2 );
662   
663   // 'large enough' empty box to cut out inner empty space
664   GeoBox*  sEmptyBox  = new GeoBox( widthTop/2, deltaZIn/2, deltaRIn/2 );
665 
666   // 'large enough' empty tube to cut out holes in the vertical plates
667   GeoTube* sEmptyTube = new GeoTube( 0, holeRadius, deltaZOut );
668                                                                       
669 
670   //----------------------------------------------------------------------------------------
671   // cut out inner space and holes in vertical plates from main trapezoid
672 
673   // positioning of empty box and tube wrt. main trapezoid
674   HepTransform3D trlEmptyBox = HepTranslateZ3D( thicknessBot/2 - thicknessTop/2 ); 
675   HepTransform3D xfEmptyTube = HepTranslateZ3D( rMean - rDistHole ) * HepRotateX3D( M_PI/2 );
676   
677   const GeoShape& sKeystoneBox = sOuterTrap->subtract( (*sEmptyBox)  << trlEmptyBox ).
678                                              subtract( (*sEmptyTube) << xfEmptyTube );
679 
680   GeoLogVol*  lKeystoneBox = new GeoLogVol( "ECTKeystoneBox", 
681                                             &sKeystoneBox, 
682                                             theMaterialManager->getMaterial(keystoneMaterial) );
683   GeoPhysVol* pKeystoneBox = new GeoPhysVol(lKeystoneBox);
684 
685 
686   //------------------------------------------------------------------------------------------
687   // Replicate and position
688 
689   // array of phi values
690   const int nPhiSectors = 8;
691   double phiVal[nPhiSectors];
692   for ( int i = 0; i < nPhiSectors; i++ )  phiVal[i] = ( 2*i + 1 ) * phi0;  
693   
694   // array of z positions
695   const int nZPos = 2;
696   double zPos[nZPos] = { -zMean, zMean };
697     
698   // auxiliary arrays to store phi values, z positions for all volumes to be replicated 
699   double phiAux[ nPhiSectors * nZPos ],  posAux[ nPhiSectors * nZPos ];
700   for ( int i = 0; i < nPhiSectors * nZPos; i++ )  
701   {
702      int ii = i % nPhiSectors, 
703          jj = i / nPhiSectors;
704      phiAux[i] = phiVal[ii]; 
705      posAux[i] = zPos[jj];
706   }
707 
708   GENFUNCTION fRot = ArrayFunction( phiAux, phiAux + nPhiSectors * nZPos ); 
709   GENFUNCTION fTrl = ArrayFunction( posAux, posAux + nPhiSectors * nZPos ); 
710   
711   TRANSFUNCTION XFKeystoneBox = Pow( HepRotateZ3D(1.0), fRot ) * 
712                                 Pow( HepTranslateZ3D(1.0), fTrl ) * 
713                                 HepTranslateX3D(rMean) * HepRotateZ3D( -M_PI/2 ) * HepRotateX3D( M_PI/2 ); 
714   
715   GeoSerialTransformer* sxKeystoneBox = new GeoSerialTransformer( pKeystoneBox, 
716                                                                   &XFKeystoneBox, 
717                                                                   nPhiSectors * nZPos );
718   container->add(sxKeystoneBox);
719 
720 }
721 
722  void EndCapToroidBuilderRDB::buildECTServiceTower( GeoPhysVol* container ) 
723 {
724   //------------------------------------------------------------------------------------------
725   //  Builds ECT Vacuum Vessel (end-plates, wall segments, staytubes)
726   //------------------------------------------------------------------------------------------
727 
728   const StoredMaterialManager*  theMaterialManager;
729   if ( StatusCode::SUCCESS != m_pDetStore->retrieve( theMaterialManager, "MATERIALS" ) ) 
730   {
731     return;
732   } 
733 
734   const double SrvTu1Dz = (*m_Aect)[0]->getFloat("SRVTU1DZ") * mm;
735   const double CryoZmoy = (*m_Aect)[0]->getFloat("CRYOZMOY") * mm;
736   const double SrvTu1He = (*m_Aect)[0]->getFloat("SRVTU1HE") * mm;
737   const double SrvTu1oW = (*m_Aect)[0]->getFloat("SRVTU1OW") * mm;
738   const double SrvTu1iW = (*m_Aect)[0]->getFloat("SRVTU1IW") * mm;
739   //const double SrvTu1Ed = (*m_Aect)[0]->getFloat("SRVTU1ED") * mm;
740   const double SrvTu2Dz = (*m_Aect)[0]->getFloat("SRVTU2DZ") * mm;
741   const double SrvTu2He = (*m_Aect)[0]->getFloat("SRVTU2HE") * mm;
742   const double SrvTu2oR = (*m_Aect)[0]->getFloat("SRVTU2OR") * mm;
743   const double SrvTu2iR = (*m_Aect)[0]->getFloat("SRVTU2IR") * mm;
744   const double SrvTu3Dz = (*m_Aect)[0]->getFloat("SRVTU3DZ") * mm; 
745   const double SrvTu3He = (*m_Aect)[0]->getFloat("SRVTU3HE") * mm;
746   const double X1temp   = (*m_Aect)[0]->getFloat("X1TEMP") * mm;
747   const double X0temp   = (*m_Aect)[0]->getFloat("X0TEMP") * mm;
748   const double SToThic1 = (*m_Ecst)[0]->getFloat("STOTHIC1") * mm;
749   const double SToThic2 = (*m_Ecst)[0]->getFloat("STOTHIC2") * mm;
750   const double SToThic3 = (*m_Ecst)[0]->getFloat("STOTHIC3") * mm;
751   //const double STOThic4 = (*m_Ecst)[0]->getFloat("STOTHIC4") * mm;
752   const double SToLeng1 = (*m_Ecst)[0]->getFloat("STOLENG1") * mm;
753   const double SToLengt = (*m_Ecst)[0]->getFloat("STOLENGT") * mm;
754   const double SToLenga = (*m_Ecst)[0]->getFloat("STOLENGA") * mm;
755   //const double SToXpref = (*m_Ecst)[0]->getFloat("STOXPREF") * mm;
756   //const double SToYpref = (*m_Ecst)[0]->getFloat("STOYPREF") * mm;
757   const double SToHeigh = (*m_Ecst)[0]->getFloat("STOHEIGH") * mm;
758   const double SToHeig1 = (*m_Ecst)[0]->getFloat("STOHEIG1") * mm;
759   const double SToHeig2 = (*m_Ecst)[0]->getFloat("STOHEIG2") * mm;
760   const double SToHeig3 = (*m_Ecst)[0]->getFloat("STOHEIG3") * mm;
761   const double SToHeig4 = (*m_Ecst)[0]->getFloat("STOHEIG4") * mm;
762   const double SToDzBot = (*m_Ecst)[0]->getFloat("STODZBOT") * mm;
763   const double SToDzIn1 = (*m_Ecst)[0]->getFloat("STODZIN1") * mm;
764   const double SToDzIn2 = (*m_Ecst)[0]->getFloat("STODZIN2") * mm;
765   const double SToDzIn3 = (*m_Ecst)[0]->getFloat("STODZIN3") * mm;
766   const double SToDzIn4 = (*m_Ecst)[0]->getFloat("STODZIN4") * mm;
767   const double SToDzIn5 = (*m_Ecst)[0]->getFloat("STODZIN5") * mm;
768   const double SToDzTop = (*m_Ecst)[0]->getFloat("STODZTOP") * mm;
769   const double SToAngle = (*m_Ecst)[0]->getFloat("STOANGLE") * deg;
770   const double SToYpos  = (*m_Ecst)[0]->getFloat("STOYPOS") * mm;
771   const double SToZpos  = (*m_Ecst)[0]->getFloat("STOZPOS") * mm;  
772 //   const double SToGeCxz = (*m_Ecst)[0]->getFloat("STOGECXZ") * mm;
773 //   const double SToGeChe = (*m_Ecst)[0]->getFloat("STOGECHE") * mm;
774 //   const double SToCLCzp = (*m_Ecst)[0]->getFloat("STOCLCZP") * mm;
775 //   const double SToUeCzp = (*m_Ecst)[0]->getFloat("STOUECZP") * mm;
776 //   const double SToUeCyp = (*m_Ecst)[0]->getFloat("STOUECYP") * mm;
777   const double CryoT1   = (*m_Aect)[0]->getFloat("CRYOT1") * mm;
778 
779    const std::string endcaptowerMaterial = getMaterial( "Aluminium" );
780 
781   const double tolerance = 0.5 * mm;
782 
783 //-----------------------
784   GeoBox* sTowerBox1 = new GeoBox( SToDzBot, SToThic1 + SToLeng1/2, SToHeig1/2 );
785   GeoBox* sTowerBox2 = new GeoBox( SToDzIn1, SToThic1 + SToLeng1/2, ( SToHeig2 - SToHeig1 - 
786                                    tan(SToAngle) * ( SToDzIn1 - SToDzIn2 - SToDzIn3 ) )/2 );
787   GeoTrd* sTowerTrap = new GeoTrd( SToDzIn1, SToDzIn2 + SToDzIn3, SToThic1 + SToLeng1/2,
788                                    SToThic1 + SToLeng1/2, tan(SToAngle) * 
789                                    ( SToDzIn1 - SToDzIn2 - SToDzIn3 )/2 );
790   GeoBox* sTowerBox3 = new GeoBox( SToDzIn3, SToThic1 + SToLeng1/2, ( SToHeigh - SToHeig3 - SToHeig4 
791                                    - SToHeig2 )/2 );
792   GeoBox* sEmptyTowerBoxHalf = new GeoBox( SToDzIn1 + tolerance, SToLeng1,
793                                             SToHeigh/2  + tolerance );
794   GeoBox* sTowerMiddelBox = new GeoBox( SToDzIn5, SToLengt/2, SToHeig3/2 );
795   GeoTrd* sTowerMiddelTrap= new GeoTrd( SToLengt/2, SToLenga/2, SToHeig3/2, SToHeig3/2, ( SToDzIn4 - 
796                                         SToDzIn5 )/2 );
797   GeoBox* sTowerTopBox = new GeoBox( SToDzTop, SToLengt/2, SToHeig4/2 - tolerance );                            
798   GeoBox* sEmptyTowerBox1 = new GeoBox( SToDzBot - SToThic2, SToLeng1/2, ( SToHeig1 + SToThic2 )/2 + 
799                                         tolerance );
800   GeoBox* sEmptyTowerBox2 = new GeoBox( SToDzIn1 - SToThic2, SToLeng1/2, ( SToHeig2 - SToHeig1 -
801                                         tan(SToAngle) * ( SToDzIn1 - SToDzIn2 - SToDzIn3 ) )/2 -
802                                         SToThic2 * ( 1 + tan(SToAngle/4) )/2 );
803   GeoTrd* sEmptyTowerTrap = new GeoTrd( SToDzIn1 - SToThic2, SToDzIn2 + SToDzIn3 - tan(SToAngle/2) 
804                                         * SToThic2, SToLeng1/2, SToLeng1/2, ( tan(SToAngle) *
805                                         ( SToDzIn1 - SToDzIn2 - SToDzIn3 ) - SToThic2 * (1 -
806                                         tan(SToAngle/4) ) )/2 + tolerance );
807   GeoBox* sEmptyTowerBox3 = new GeoBox( SToDzIn3 - SToThic2, SToLeng1/2, ( SToHeigh - SToHeig3 - 
808                                         SToHeig4 - SToHeig2 + SToThic2 )/2 + tolerance );
809   GeoBox* sEmptyTowerMiddelBox = new GeoBox( SToDzIn3 - SToThic2, SToLengt/2 - SToThic3, SToHeig3 +
810                                                 tolerance );
811                                                 
812 //--------------------------------------------------------------------------------------------------                                    
813   HepTransform3D trlTowerBox2 = HepTranslateZ3D( ( SToHeig2 - tan(SToAngle) * ( SToDzIn1 - SToDzIn2 -
814                                                      SToDzIn3 ) )/2 );
815   HepTransform3D trlTowerTrap = HepTranslateZ3D(  SToHeig2 - ( tan(SToAngle) *
816                                                  ( SToDzIn1 - SToDzIn2 - SToDzIn3 ) + SToHeig1 )/2 );
817   HepTransform3D trlTowerBox3 = HepTranslateZ3D( ( SToHeig2 + SToHeigh - SToHeig3 - SToHeig4
818                                                   - SToHeig1 )/2  );
819   HepTransform3D trlTowerMiddelBox = HepTranslateZ3D( SToHeigh - SToHeig4 - SToHeig3/2 -
820                                                              SToHeig1/2 );
821   HepTransform3D trlTowerMiddelTrap= HepTranslate3D( (SToDzIn5 + SToDzIn4)/2, 0, 
822                                                      SToHeigh - SToHeig4 - SToHeig3/2 - SToHeig1/2 )  
823                                                      * HepRotateY3D(M_PI/2) * HepRotateZ3D(M_PI/2);
824   HepTransform3D trlTowerTopBox = HepTranslateZ3D( SToHeigh - SToHeig4/2 - SToHeig1/2 );
825   
826   HepTransform3D trlEmptyTowerMiddelBox = HepTranslateZ3D( SToHeigh - SToHeig4 - SToHeig3/2 -
827                                                              SToHeig1/2 );                                                   
828   HepTransform3D trlEmptyTowerBox1 = HepTranslateZ3D( SToThic2/2 ); 
829   HepTransform3D trlEmptyTowerBox2 = HepTranslateZ3D( SToThic2 * ( 1 - tan(SToAngle/4) )/2 
830                                                       + ( SToHeig2 - tan(SToAngle) * 
831                                                       ( SToDzIn1 - SToDzIn2 - SToDzIn3 ) )/2 );  
832   HepTransform3D trlEmptyTowerBox3 = HepTranslateZ3D( ( SToHeigh - SToHeig3 - SToHeig4 )/2 +
833                                                       SToHeig2/2 - SToHeig1/2 - SToThic2/2 );
834   HepTransform3D trlEmptyTowerBoxHalf = HepTranslate3D( -SToDzIn1, 0, 
835                                                         ( SToHeigh - SToHeig1 )/2 );  
836   HepTransform3D trlEmptyTowerTrap = HepTranslateZ3D( SToHeig2 - SToThic2 * ( 1 + tan(SToAngle/4) )/2
837                                                      - ( SToHeig1 + tan(SToAngle) *
838                                                       ( SToDzIn1 - SToDzIn2 - SToDzIn3 ) )/2 );                                         
839 //--------------------------------------------------------------------------------------------------                                    
840   const GeoShape& sEndCapTower = sTowerBox1->add( (*sTowerBox2) << trlTowerBox2 ).
841                                              add( (*sTowerTrap) << trlTowerTrap ).
842                                              add( (*sTowerBox3) << trlTowerBox3 ).
843                                              add( (*sTowerMiddelBox) << trlTowerMiddelBox ).
844                                              add( (*sTowerMiddelTrap) << trlTowerMiddelTrap ).
845                                              add( (*sTowerTopBox) << trlTowerTopBox ).
846                                  subtract( (*sEmptyTowerBox1) << trlEmptyTowerBox1 ).
847                                  subtract( (*sEmptyTowerBox2) << trlEmptyTowerBox2 ).
848                                  subtract( (*sEmptyTowerTrap) << trlEmptyTowerTrap ).
849                                  subtract( (*sEmptyTowerBox3) << trlEmptyTowerBox3 ).
850                                  subtract( (*sEmptyTowerMiddelBox) << trlEmptyTowerMiddelBox ).
851                                  subtract( (*sEmptyTowerBoxHalf) << trlEmptyTowerBoxHalf );
852 
853   GeoLogVol*  lEndCapTower = new GeoLogVol( "ECTTower",
854                                             &sEndCapTower,
855                                             theMaterialManager->getMaterial(endcaptowerMaterial) );
856   GeoPhysVol* pEndCapTower = new GeoPhysVol(lEndCapTower);                      
857 
858   //------------------------------------------------------------------------------------------
859   // Replicate and position
860 
861   // array of z positions
862   const int nZPos = 2;
863   double zPos[nZPos] = { -SToZpos - CryoZmoy, SToZpos + CryoZmoy };
864 
865   // array of rotation angles (flipping around y-axis)
866   double rotAngle[nZPos] = { 0, M_PI };
867 
868   GENFUNCTION fRot = ArrayFunction( rotAngle, rotAngle + nZPos );
869   GENFUNCTION fTrl = ArrayFunction( zPos,     zPos     + nZPos );
870 
871   TRANSFUNCTION XFEndCapTower = Pow( HepTranslateZ3D(1.0), fTrl ) *
872                                 HepTranslateY3D(SToYpos + SToHeig1/2) *             // constant displacement
873                                 Pow( HepRotateY3D(1.0), fRot ) *
874                                 HepRotateX3D(-M_PI/2) * HepRotateZ3D(-M_PI/2);
875 
876   GeoSerialTransformer* sxEndCapTower = new GeoSerialTransformer( pEndCapTower, &XFEndCapTower, nZPos );
877 
878   container->add(sxEndCapTower);
879   
880 //----------------needfull volumes -----
881 
882   GeoBox* sBottomTowerBox = new GeoBox( SToLeng1/2, SToThic2/2, SToDzBot/2 - SToThic2 );
883   GeoShape* sBackTowerWall= new GeoBox( SToLeng1/2, SToHeigh/2, SToThic2/2 );
884   GeoBox* sSrvTurBox1     = new GeoBox( SrvTu1oW/2, SrvTu1He/2, SrvTu1oW/2 );
885   GeoBox* sSrvTurBox2     = new GeoBox( X1temp/2, SrvTu1He/2, X1temp/2 );
886   GeoBox* sEmptySrvTurBox1= new GeoBox( SrvTu1iW/2, SrvTu1He/2, SrvTu1iW/2 );
887   GeoBox* sEmptySrvTurBox2= new GeoBox( X0temp/2, SrvTu1He/2, X0temp/2 );
888   GeoTube* sTubeBotSrvTur = new GeoTube( SrvTu2iR, SrvTu2oR, SrvTu2He/2 - tolerance );
889   GeoTube* sTubeMidSrvTur = new GeoTube( SrvTu2iR, SrvTu2oR, (SrvTu2Dz - SrvTu3Dz)/2 + SrvTu2oR -
890                                             tolerance );
891   GeoTube* sTubeTopSrvTur = new GeoTube( SrvTu2iR, SrvTu2oR, SrvTu3He/2 + SrvTu2oR - tolerance );
892   GeoBox* sEmptyEdgeTubeBox = new GeoBox( SrvTu2oR * sqrt(2) + tolerance,
893                                             SrvTu2oR * sqrt(2) + tolerance,
894                                             SrvTu2oR * sqrt(2) + tolerance );
895 
896   const GeoShape& sSrvTurOut = sSrvTurBox1->intersect( (*sSrvTurBox2) << HepRotateY3D(M_PI/4) );
897   const GeoShape& sSrvTurIn  = sEmptySrvTurBox1->intersect( (*sEmptySrvTurBox2) <<
898                                                              HepRotateY3D(M_PI/4) );
899   const GeoShape& sBotSrvTur = sTubeBotSrvTur->subtract( (*sEmptyEdgeTubeBox) <<
900                                                 HepTranslate3D( 0, SrvTu2oR, SrvTu2He/2 ) 
901                                                 * HepRotateX3D(M_PI/4) );
902   const GeoShape& sMidSrvTur = sTubeMidSrvTur->subtract( (*sEmptyEdgeTubeBox) <<
903                                                 HepTranslate3D( 0, -SrvTu2oR, (SrvTu2Dz - SrvTu3Dz)/2
904                                                 + SrvTu2oR ) * HepRotateX3D(M_PI/4) ).
905                                                 subtract( (*sEmptyEdgeTubeBox) <<
906                                                 HepTranslate3D( 0, SrvTu2oR, -(SrvTu2Dz - SrvTu3Dz)/2
907                                                 - SrvTu2oR ) * HepRotateX3D(-M_PI/4) );  
908   const GeoShape& sTopSrvTur = sTubeTopSrvTur->subtract( (*sEmptyEdgeTubeBox) <<
909                                                 HepTranslate3D( 0, -SrvTu2oR, -SrvTu3He/2 - SrvTu2oR ) 
910                                                 * HepRotateX3D(M_PI/4) );
911 
912 //--------------------Bottom Tower Plate-------------------------------------------------------
913 
914   const GeoShape& sBottomTower = sBottomTowerBox->subtract( (sSrvTurOut) << 
915                                                             HepTranslateZ3D( 0. ) );
916                                                             
917   GeoLogVol*  lBottomTower = new GeoLogVol( "ECTBottomTower",
918                                             &sBottomTower,
919                                             theMaterialManager->getMaterial(endcaptowerMaterial) );
920   GeoPhysVol* pBottomTower = new GeoPhysVol(lBottomTower);
921   //------------------------------------------------------------------------------------------
922   // Replicate and position
923 
924   // array of z positions
925   double zPosBot[nZPos] = { -SToZpos - CryoZmoy + SToDzBot/2, SToZpos + CryoZmoy - SToDzBot/2 };
926 
927   GENFUNCTION fTrlBot = ArrayFunction( zPosBot,     zPosBot     + nZPos );
928 
929   TRANSFUNCTION XFBottomTower = Pow( HepTranslateZ3D(1.0), fTrlBot ) *
930                                 HepTranslateY3D(SToYpos + SToThic2/2) *             // constant displacement
931                                 Pow( HepRotateY3D(1.0), fRot ); 
932 
933   GeoSerialTransformer* sxBottomTower = new GeoSerialTransformer( pBottomTower, &XFBottomTower
934                                                                 , nZPos );
935 
936   container->add(sxBottomTower);
937 
938 //-------------------Back Tower Plate--------------------------------------------------------
939   GeoLogVol*  lBackTowerWall = new GeoLogVol( "ECTBackTowerWall",
940                                             &*sBackTowerWall,
941                                             theMaterialManager->getMaterial(endcaptowerMaterial) );
942   GeoPhysVol* pBackTowerWall = new GeoPhysVol(lBackTowerWall);
943   //------------------------------------------------------------------------------------------
944   // Replicate and position
945 
946   // array of z positions 
947   double zPosBackWall[nZPos] = { -SToZpos - CryoZmoy + SToThic2/2,
948                                  SToZpos + CryoZmoy - SToThic2/2 };
949 
950   GENFUNCTION fTrlBackWall = ArrayFunction( zPosBackWall,     zPosBackWall     + nZPos );
951 
952   TRANSFUNCTION XFBackTowerWall = Pow( HepTranslateZ3D(1.0), fTrlBackWall ) *
953                                 HepTranslateY3D(SToYpos + SToHeigh/2) *             // constant displacement
954                                 Pow( HepRotateY3D(1.0), fRot );
955 
956   GeoSerialTransformer* sxBackTowerWall = new GeoSerialTransformer( pBackTowerWall, &XFBackTowerWall
957                                                                 , nZPos );
958 
959   container->add(sxBackTowerWall);
960   
961 //---------------Service Turret-----------------------
962                                                     
963   const GeoShape& sSrvTurret   = sSrvTurOut.subtract( (sSrvTurIn) <<
964                                         HepTranslateY3D( ( SrvTu1iW - SrvTu1oW )/2 ) ).
965                                         add( (sBotSrvTur) << HepTranslate3D( 0, SrvTu1He/2 + 
966                                         SrvTu2He/2, ( SrvTu2Dz-SrvTu1Dz ) ) *
967                                         HepRotateX3D(-M_PI/2) ).
968                                         add( (sMidSrvTur) << HepTranslate3D( 0., SrvTu1He/2 +
969                                         SrvTu2He - SrvTu2oR, -(SrvTu2Dz - SrvTu3Dz)/2 + 
970                                         ( SrvTu2Dz-SrvTu1Dz ) ) ).
971                                         add( (sTopSrvTur) << HepTranslate3D( 0., SrvTu1He/2 +
972                                         SrvTu2He + SrvTu3He/2 - SrvTu2oR, 
973                                         -(SrvTu2Dz - SrvTu3Dz)+ ( SrvTu2Dz-SrvTu1Dz ) ) 
974                                         * HepRotateX3D(-M_PI/2) );
975                                                 
976   GeoLogVol*  lSrvTurret = new GeoLogVol( "ECTServiceTurretTower",
977                                             &sSrvTurret,
978                                             theMaterialManager->getMaterial(endcaptowerMaterial) );
979   GeoPhysVol* pSrvTurret = new GeoPhysVol(lSrvTurret);
980   //------------------------------------------------------------------------------------------
981   // Replicate and position
982 
983   // array of z positions
984   double zPosSrvTurret[nZPos] = { -SToZpos - CryoZmoy + SToDzBot/2,
985                                     SToZpos + CryoZmoy - SToDzBot/2 };
986 
987   GENFUNCTION fTrlSrvTurret = ArrayFunction( zPosSrvTurret,  zPosSrvTurret     + nZPos );
988 
989   TRANSFUNCTION XFSrvTurret = Pow( HepTranslateZ3D(1.0), fTrlSrvTurret ) *
990                                 HepTranslateY3D( CryoT1 + SrvTu1He/2 ) *             // constant displacement
991                                 Pow( HepRotateY3D(1.0), fRot );
992 
993   GeoSerialTransformer* sxSrvTurret = new GeoSerialTransformer( pSrvTurret, &XFSrvTurret
994                                                                 , nZPos );
995 
996   container->add(sxSrvTurret);
997 
998 }
999 
1000 std::string EndCapToroidBuilderRDB::getMaterial( std::string materialName ) 
1001 {
1002   MsgStream log(Athena::getMessageSvc(), "MuonGeoModel");
1003   if ( materialName == "Alum" )
1004   {
1005     return "std::Aluminium";
1006   }
1007   else if ( materialName == "Iron" )  
1008   {
1009     return "std::Iron";
1010   }  
1011   else if ( materialName == "Fe50"  ||  materialName == "Al67" )   
1012   {
1013     return "toro::" + materialName;
1014   }
1015   else 
1016   {
1017     log  <<  " EndCapToroidBuilderRDB::getMaterial: material "  <<  materialName  <<  " not defined! "  
1018          <<  " Take Aluminium instead." 
1019          <<  endreq;
1020     return "std::Aluminium";           
1021   }  
1022 }  
1023 
1024 
1025 } // namespace MuonGM 
1026 

source navigation ] diff markup ] identifier search ] general search ]

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. Valid HTML 4.01!