CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_6_1_2_SLHC4_patch1/src/Geometry/EcalCommonData/src/DDEcalBarrelNewAlgo.cc

Go to the documentation of this file.
00001 
00003 // File: DDEcalBarrelNewAlgo.cc
00004 // Description: Geometry factory class for Ecal Barrel
00006 
00007 #include <cmath>
00008 #include <algorithm>
00009 
00010 #include "FWCore/MessageLogger/interface/MessageLogger.h"
00011 #include "DetectorDescription/Base/interface/DDutils.h"
00012 #include "DetectorDescription/Core/interface/DDLogicalPart.h"
00013 #include "DetectorDescription/Core/interface/DDSolid.h"
00014 #include "DetectorDescription/Core/interface/DDCurrentNamespace.h"
00015 #include "DetectorDescription/Base/interface/DDTranslation.h"
00016 #include "Geometry/EcalCommonData/interface/DDEcalBarrelNewAlgo.h"
00017 #include "CLHEP/Units/GlobalSystemOfUnits.h"
00018 
00019 #include <CLHEP/Geometry/Point3D.h>
00020 #include <CLHEP/Geometry/Vector3D.h>
00021 #include <CLHEP/Geometry/Transform3D.h>
00022 
00023 namespace std{} using namespace std;
00024 
00025 DDEcalBarrelNewAlgo::DDEcalBarrelNewAlgo() :
00026   m_idNameSpace  ( "" ),
00027   m_BarName      ( "" ),
00028   m_BarMat       ( "" ),
00029   m_vecBarZPts   (    ),
00030   m_vecBarRMin   (    ),
00031   m_vecBarRMax   (    ),
00032   m_vecBarTran   (    ),
00033   m_vecBarRota   (    ),
00034   m_vecBarRota2  (    ),
00035   m_vecBarRota3  (    ),
00036   m_BarPhiLo     (0),
00037   m_BarPhiHi     (0),
00038   m_BarHere      (0),
00039   m_SpmName      (""),
00040   m_SpmMat       (""),
00041   m_vecSpmZPts   (),
00042   m_vecSpmRMin   (),
00043   m_vecSpmRMax   (),
00044   m_vecSpmTran   (),
00045   m_vecSpmRota   (),
00046   m_vecSpmBTran  (),
00047   m_vecSpmBRota  (),
00048   m_SpmNPerHalf  (0),
00049   m_SpmLowPhi    (0),
00050   m_SpmDelPhi    (0),
00051   m_SpmPhiOff    (0),
00052   m_vecSpmHere   (),
00053   m_SpmCutName   (""),
00054   m_SpmCutThick  (0),
00055   m_SpmCutShow   (0),
00056   m_vecSpmCutTM  (),
00057   m_vecSpmCutTP  (),
00058   m_SpmCutRM     (0),
00059   m_SpmCutRP     (0),
00060   m_SpmExpThick  (0),
00061   m_SpmExpWide   (0),
00062   m_SpmExpYOff   (0),
00063   m_SpmSideName  (""),
00064   m_SpmSideMat   (""),
00065   m_SpmSideHigh  (0),
00066   m_SpmSideThick (0),
00067   m_SpmSideYOffM (0),
00068   m_SpmSideYOffP (0),
00069   m_NomCryDimAF  (0),    
00070   m_NomCryDimLZ  (0),  
00071   m_vecNomCryDimBF (),
00072   m_vecNomCryDimCF (),
00073   m_vecNomCryDimAR (),
00074   m_vecNomCryDimBR (),
00075   m_vecNomCryDimCR (),
00076   m_UnderAF      (0),  
00077   m_UnderLZ      (0),
00078   m_UnderBF      (0),
00079   m_UnderCF      (0),
00080   m_UnderAR      (0),
00081   m_UnderBR      (0),
00082   m_UnderCR      (0),
00083   m_WallThAlv    (0),
00084   m_WrapThAlv    (0),
00085   m_ClrThAlv     (0),
00086   m_vecGapAlvEta (),
00087   m_WallFrAlv    (0),
00088   m_WrapFrAlv    (0),
00089   m_ClrFrAlv     (0),
00090   m_WallReAlv    (0),
00091   m_WrapReAlv    (0),
00092   m_ClrReAlv     (0),
00093   m_NCryTypes    (0),
00094   m_NCryPerAlvEta (0),
00095   m_CryName      (""),
00096   m_ClrName      (""),
00097   m_WrapName     (""),
00098   m_WallName     (""),
00099   m_CryMat       (""),
00100   m_ClrMat       (""),
00101   m_WrapMat      (""),
00102   m_WallMat      (""),
00103 
00104   m_capName      (""),
00105   m_capHere      (0),
00106   m_capMat       (""),
00107   m_capXSize     (0),
00108   m_capYSize     (0),
00109   m_capThick     (0),
00110 
00111   m_CERName      (""),
00112   m_CERMat       (""),
00113   m_CERXSize     (0),
00114   m_CERYSize     (0),
00115   m_CERThick     (0),
00116 
00117   m_BSiName      (""),
00118   m_BSiMat       (""),
00119   m_BSiXSize     (0),
00120   m_BSiYSize     (0),
00121   m_BSiThick     (0),
00122 
00123   m_APDName      (""),
00124   m_APDMat       (""),
00125   m_APDSide      (0),
00126   m_APDThick     (0),
00127   m_APDZ         (0),
00128   m_APDX1        (0),
00129   m_APDX2        (0),
00130 
00131   m_ATJName      (""),
00132   m_ATJMat       (""),
00133   m_ATJThick     (0),
00134 
00135   m_SGLName      (""),
00136   m_SGLMat       (""),
00137   m_SGLThick     (0),
00138 
00139   m_AGLName      (""),
00140   m_AGLMat       (""),
00141   m_AGLThick     (0),
00142 
00143   m_ANDName      (""),
00144   m_ANDMat       (""),
00145   m_ANDThick     (0),
00146 
00147   m_WebHere      (0),
00148   m_WebPlName    (""),    
00149   m_WebClrName   (""),    
00150   m_WebPlMat     (""),
00151   m_WebClrMat    (""),
00152   m_vecWebPlTh   (),
00153   m_vecWebClrTh  (),
00154   m_vecWebLength (),
00155   m_IlyHere      (0),
00156   m_IlyName      (),
00157   m_IlyPhiLow    (0),
00158   m_IlyDelPhi    (0),
00159   m_vecIlyMat    (),
00160   m_vecIlyThick  (),
00161   m_IlyPipeName      (""),
00162   m_IlyPipeHere      (0),
00163   m_IlyPipeMat       (""),
00164   m_IlyPipeOD        (0),
00165   m_IlyPipeID        (0),
00166   m_vecIlyPipeLength (),
00167   m_vecIlyPipeType   (),
00168   m_vecIlyPipePhi    (),
00169   m_vecIlyPipeZ      (),
00170   m_IlyPTMName        (""),
00171   m_IlyPTMHere        (0),
00172   m_IlyPTMMat         (""),
00173   m_IlyPTMWidth       (0),
00174   m_IlyPTMLength      (0),
00175   m_IlyPTMHeight      (0),
00176   m_vecIlyPTMZ        (),
00177   m_vecIlyPTMPhi      (),
00178   m_IlyFanOutName  (""),
00179   m_IlyFanOutHere  (0),
00180   m_IlyFanOutMat   (""),
00181   m_IlyFanOutWidth (0),
00182   m_IlyFanOutLength(0),
00183   m_IlyFanOutHeight(0),
00184   m_vecIlyFanOutZ  (),
00185   m_vecIlyFanOutPhi(),
00186   m_IlyDiffName    (""),
00187   m_IlyDiffMat     (""),
00188   m_IlyDiffOff     (0),
00189   m_IlyDiffLength  (0),
00190   m_IlyBndlName    (""),
00191   m_IlyBndlMat     (""),
00192   m_IlyBndlOff     (0),
00193   m_IlyBndlLength  (0),
00194   m_IlyFEMName     (""),
00195   m_IlyFEMMat      (""),
00196   m_IlyFEMWidth    (0),
00197   m_IlyFEMLength   (0),
00198   m_IlyFEMHeight   (0),
00199   m_vecIlyFEMZ     (),
00200   m_vecIlyFEMPhi   (),
00201   m_HawRName     (""),
00202   m_FawName      (""),
00203   m_FawHere      (0),
00204   m_HawRHBIG     (0),
00205   m_HawRhsml     (0),
00206   m_HawRCutY     (0),
00207   m_HawRCutZ     (0),
00208   m_HawRCutDelY  (0),
00209   m_HawYOffCry   (0),
00210   m_NFawPerSupm  (0),
00211   m_FawPhiOff    (0),
00212   m_FawDelPhi    (0),
00213   m_FawPhiRot    (0),
00214   m_FawRadOff    (0),
00215   m_GridHere      (0),
00216   m_GridName     (""),
00217   m_GridMat      (""),
00218   m_GridThick    (0),
00219   m_BackXOff     (0),
00220   m_BackYOff     (0),
00221   m_BackHere      (0),
00222   m_BackSideName          (""),
00223   m_BackSideHere          (0),
00224   m_BackSideLength        (0),
00225   m_BackSideHeight        (0),
00226   m_BackSideWidth         (0),
00227   m_BackSideYOff1        (0),
00228   m_BackSideYOff2        (0),
00229   m_BackSideAngle        (0),
00230   m_BackSideMat           (""),
00231   m_BackPlateName    (""),
00232   m_BackPlateHere          (0),
00233   m_BackPlateLength  (0),
00234   m_BackPlateThick   (0),
00235   m_BackPlateWidth   (0),
00236   m_BackPlateMat     (""),
00237   m_BackPlate2Name    (""),
00238   m_BackPlate2Thick   (0),
00239   m_BackPlate2Mat     (""),
00240   m_GrilleName      (""),
00241   m_GrilleHere      (0),
00242   m_GrilleThick     (0),
00243   m_GrilleWidth     (0),
00244   m_GrilleZSpace    (0),
00245   m_GrilleMat       (""),
00246   m_vecGrilleHeight (),
00247   m_vecGrilleZOff   (),
00248   m_GrEdgeSlotName     (""),
00249   m_GrEdgeSlotMat      (""),
00250   m_GrEdgeSlotHere     (0),
00251   m_GrEdgeSlotHeight   (0),
00252   m_GrEdgeSlotWidth    (0),
00253   m_GrMidSlotName      (""),
00254   m_GrMidSlotMat       (""),
00255   m_GrMidSlotHere      (0),
00256   m_GrMidSlotWidth     (0),
00257   m_GrMidSlotXOff      (0),
00258   m_vecGrMidSlotHeight (),
00259   m_BackPipeHere      (0),
00260   m_BackPipeName    (""),
00261   m_vecBackPipeDiam (),
00262   m_vecBackPipeThick (),
00263   m_BackPipeMat     (""),
00264   m_BackPipeWaterMat (""),
00265 
00266   m_vecBackCoolName       (),
00267   m_BackCoolHere      (0),
00268   m_BackCoolBarHere      (0),
00269   m_BackCoolBarWidth       (0),
00270   m_BackCoolBarHeight      (0),
00271   m_BackCoolMat           (""),
00272   m_BackCoolBarName       (""),
00273   m_BackCoolBarThick      (0),
00274   m_BackCoolBarMat        (""),
00275   m_BackCoolBarSSName     (""),
00276   m_BackCoolBarSSThick    (0),
00277   m_BackCoolBarSSMat      (""),
00278   m_BackCoolBarWaName     (""),
00279   m_BackCoolBarWaThick    (0),
00280   m_BackCoolBarWaMat      (""),
00281   m_BackCoolVFEHere      (0),
00282   m_BackCoolVFEName       (""),
00283   m_BackCoolVFEMat        (""),
00284   m_BackVFEName           (""),
00285   m_BackVFEMat            (""),
00286   m_vecBackVFELyrThick    (),
00287   m_vecBackVFELyrName     (),
00288   m_vecBackVFELyrMat      (),
00289   m_vecBackCoolNSec       (),
00290   m_vecBackCoolSecSep     (),
00291   m_vecBackCoolNPerSec    (),     
00292 
00293   m_BackMiscHere      (0),
00294   m_vecBackMiscThick (),
00295   m_vecBackMiscName  (),
00296   m_vecBackMiscMat   (),
00297   m_BackCBStdSep         (0),
00298   m_PatchPanelHere      (0),
00299   m_PatchPanelName   (""),
00300   m_vecPatchPanelThick (),
00301   m_vecPatchPanelNames  (),
00302   m_vecPatchPanelMat   (),
00303   m_BackCoolTankHere      (0),
00304   m_BackCoolTankName    (""),
00305   m_BackCoolTankWidth   (0),
00306   m_BackCoolTankThick   (0),
00307   m_BackCoolTankMat     (""),
00308   m_BackCoolTankWaName  (""),
00309   m_BackCoolTankWaWidth (0),
00310   m_BackCoolTankWaMat   (""),
00311   m_BackBracketName     (""),
00312   m_BackBracketHeight   (0),
00313   m_BackBracketMat      (""),
00314 
00315   m_DryAirTubeHere      (0),
00316   m_DryAirTubeName      (""),
00317   m_MBCoolTubeNum       (0),
00318   m_DryAirTubeInnDiam   (0),
00319   m_DryAirTubeOutDiam   (0),
00320   m_DryAirTubeMat       (""),
00321   m_MBCoolTubeHere      (0),
00322   m_MBCoolTubeName      (""),
00323   m_MBCoolTubeInnDiam   (0),
00324   m_MBCoolTubeOutDiam   (0),
00325   m_MBCoolTubeMat       (""),
00326   m_MBManifHere      (0),
00327   m_MBManifName         (""),
00328   m_MBManifInnDiam      (0),
00329   m_MBManifOutDiam      (0),
00330   m_MBManifMat          (""),
00331   m_MBLyrHere      (0),
00332   m_vecMBLyrThick       (0),
00333   m_vecMBLyrName        (),
00334   m_vecMBLyrMat         (),
00335 
00336 
00337   m_PincerRodHere      (0),
00338   m_PincerRodName      (""),
00339   m_PincerRodMat       (""),
00340   m_vecPincerRodAzimuth(),
00341   m_PincerEnvName      (""),
00342   m_PincerEnvMat       (""),
00343   m_PincerEnvWidth     (0),
00344   m_PincerEnvHeight    (0),
00345   m_PincerEnvLength    (0),
00346   m_vecPincerEnvZOff   (),
00347   m_PincerBlkName      (""),
00348   m_PincerBlkMat       (""),
00349   m_PincerBlkLength    (0),
00350   m_PincerShim1Name    (""),
00351   m_PincerShimHeight   (0),
00352   m_PincerShim2Name    (""),
00353   m_PincerShimMat      (""),
00354   m_PincerShim1Width   (0),
00355   m_PincerShim2Width   (0),
00356   m_PincerCutName      (""),
00357   m_PincerCutMat       (""),
00358   m_PincerCutWidth    (0),
00359   m_PincerCutHeight    (0)
00360 
00361 {
00362    LogDebug("EcalGeom") << "DDEcalBarrelAlgo info: Creating an instance" ;
00363 }
00364 
00365 DDEcalBarrelNewAlgo::~DDEcalBarrelNewAlgo() {}
00366 
00367 
00368 
00369 
00370 void DDEcalBarrelNewAlgo::initialize(const DDNumericArguments      & nArgs,
00371                                      const DDVectorArguments       & vArgs,
00372                                      const DDMapArguments          & /*mArgs*/,
00373                                      const DDStringArguments       & sArgs,
00374                                      const DDStringVectorArguments & vsArgs) {
00375 
00376    LogDebug("EcalGeom") << "DDEcalBarrelAlgo info: Initialize" ;
00377    m_idNameSpace = DDCurrentNamespace::ns();
00378    // TRICK!
00379    m_idNameSpace = parent().name().ns();
00380    // barrel parent volume
00381    m_BarName     = sArgs["BarName" ] ;
00382    m_BarMat      = sArgs["BarMat"  ] ;
00383    m_vecBarZPts  = vArgs["BarZPts" ] ;
00384    m_vecBarRMin  = vArgs["BarRMin" ] ;
00385    m_vecBarRMax  = vArgs["BarRMax" ] ;
00386    m_vecBarTran  = vArgs["BarTran" ] ;
00387    m_vecBarRota  = vArgs["BarRota" ] ;
00388    m_vecBarRota2 = vArgs["BarRota2" ] ;
00389    m_vecBarRota3 = vArgs["BarRota3" ] ;
00390    m_BarPhiLo    = nArgs["BarPhiLo" ] ;
00391    m_BarPhiHi    = nArgs["BarPhiHi" ] ;
00392    m_BarHere     = nArgs["BarHere" ] ;
00393 
00394    m_SpmName     = sArgs["SpmName"] ;
00395    m_SpmMat      = sArgs["SpmMat" ] ;
00396    m_vecSpmZPts  = vArgs["SpmZPts"] ;
00397    m_vecSpmRMin  = vArgs["SpmRMin"] ;
00398    m_vecSpmRMax  = vArgs["SpmRMax"] ;
00399    m_vecSpmTran  = vArgs["SpmTran"] ;
00400    m_vecSpmRota  = vArgs["SpmRota"] ;
00401    m_vecSpmBTran = vArgs["SpmBTran"] ;
00402    m_vecSpmBRota = vArgs["SpmBRota"] ;
00403    m_SpmNPerHalf = static_cast<unsigned int> (nArgs["SpmNPerHalf"]) ;
00404    m_SpmLowPhi   = nArgs["SpmLowPhi"] ;
00405    m_SpmDelPhi   = nArgs["SpmDelPhi"] ;
00406    m_SpmPhiOff   = nArgs["SpmPhiOff"] ;
00407    m_vecSpmHere  = vArgs["SpmHere"] ;
00408    m_SpmCutName  = sArgs["SpmCutName"] ;
00409    m_SpmCutThick = nArgs["SpmCutThick"] ;
00410    m_SpmCutShow  = int(nArgs["SpmCutShow"]) ;
00411    m_vecSpmCutTM = vArgs["SpmCutTM"] ;
00412    m_vecSpmCutTP = vArgs["SpmCutTP"] ;
00413    m_SpmCutRM    = nArgs["SpmCutRM"] ;
00414    m_SpmCutRP    = nArgs["SpmCutRP"] ;
00415    m_SpmExpThick = nArgs["SpmExpThick"] ;
00416    m_SpmExpWide  = nArgs["SpmExpWide"] ;
00417    m_SpmExpYOff  = nArgs["SpmExpYOff"] ;
00418    m_SpmSideName = sArgs["SpmSideName"] ;
00419    m_SpmSideMat  = sArgs["SpmSideMat" ] ;
00420    m_SpmSideHigh = nArgs["SpmSideHigh"] ;
00421    m_SpmSideThick= nArgs["SpmSideThick"] ;
00422    m_SpmSideYOffM= nArgs["SpmSideYOffM"] ;
00423    m_SpmSideYOffP= nArgs["SpmSideYOffP"] ;
00424 
00425    m_NomCryDimAF    = nArgs["NomCryDimAF"] ;
00426    m_NomCryDimLZ    = nArgs["NomCryDimLZ"] ;
00427    m_vecNomCryDimBF = vArgs["NomCryDimBF"] ;
00428    m_vecNomCryDimCF = vArgs["NomCryDimCF"] ;
00429    m_vecNomCryDimAR = vArgs["NomCryDimAR"] ;
00430    m_vecNomCryDimBR = vArgs["NomCryDimBR"] ;
00431    m_vecNomCryDimCR = vArgs["NomCryDimCR"] ;
00432 
00433    m_UnderAF = nArgs["UnderAF"] ; 
00434    m_UnderLZ = nArgs["UnderLZ"] ; 
00435    m_UnderBF = nArgs["UnderBF"] ; 
00436    m_UnderCF = nArgs["UnderCF"] ; 
00437    m_UnderAR = nArgs["UnderAR"] ; 
00438    m_UnderBR = nArgs["UnderBR"] ; 
00439    m_UnderCR = nArgs["UnderCR"] ; 
00440 
00441    m_WallThAlv = nArgs["WallThAlv"] ;
00442    m_WrapThAlv = nArgs["WrapThAlv"] ;
00443    m_ClrThAlv  = nArgs["ClrThAlv"] ;
00444    m_vecGapAlvEta = vArgs["GapAlvEta"] ;
00445 
00446    m_WallFrAlv = nArgs["WallFrAlv"] ;
00447    m_WrapFrAlv = nArgs["WrapFrAlv"] ;
00448    m_ClrFrAlv  = nArgs["ClrFrAlv"] ;
00449 
00450    m_WallReAlv = nArgs["WallReAlv"] ;
00451    m_WrapReAlv = nArgs["WrapReAlv"] ;
00452    m_ClrReAlv  = nArgs["ClrReAlv"] ;
00453 
00454    m_NCryTypes     = static_cast<unsigned int> ( nArgs["NCryTypes"] ) ;
00455    m_NCryPerAlvEta = static_cast<unsigned int> ( nArgs["NCryPerAlvEta"] ) ;
00456 
00457    m_CryName  = sArgs["CryName"] ;
00458    m_ClrName  = sArgs["ClrName"] ;
00459    m_WrapName = sArgs["WrapName"] ; 
00460    m_WallName = sArgs["WallName"] ; 
00461 
00462    m_CryMat  = sArgs["CryMat"] ; 
00463    m_ClrMat  = sArgs["ClrMat"] ; 
00464    m_WrapMat = sArgs["WrapMat"] ; 
00465    m_WallMat = sArgs["WallMat"] ;
00466 
00467    m_capName  = sArgs["CapName"] ;
00468    m_capHere  = nArgs["CapHere"] ;
00469    m_capMat   = sArgs["CapMat"] ;
00470    m_capXSize = nArgs["CapXSize"] ;
00471    m_capYSize = nArgs["CapYSize"] ;
00472    m_capThick = nArgs["CapThick"] ;
00473 
00474    m_CERName  = sArgs["CerName"] ;
00475    m_CERMat   = sArgs["CerMat"] ;
00476    m_CERXSize = nArgs["CerXSize"] ;
00477    m_CERYSize = nArgs["CerYSize"] ;
00478    m_CERThick = nArgs["CerThick"] ;
00479 
00480    m_BSiName  = sArgs["BSiName"] ;
00481    m_BSiMat   = sArgs["BSiMat"] ;
00482    m_BSiXSize = nArgs["BSiXSize"] ;
00483    m_BSiYSize = nArgs["BSiYSize"] ;
00484    m_BSiThick = nArgs["BSiThick"] ;
00485 
00486    m_APDName  = sArgs["APDName"] ;
00487    m_APDMat   = sArgs["APDMat"] ;
00488    m_APDSide  = nArgs["APDSide"] ;
00489    m_APDThick = nArgs["APDThick"] ;
00490    m_APDZ     = nArgs["APDZ"] ;
00491    m_APDX1    = nArgs["APDX1"] ;
00492    m_APDX2    = nArgs["APDX2"] ;
00493 
00494    m_ATJName  = sArgs["ATJName"] ;
00495    m_ATJMat   = sArgs["ATJMat"] ;
00496    m_ATJThick = nArgs["ATJThick"] ;
00497 
00498    m_SGLName  = sArgs["SGLName"] ;
00499    m_SGLMat   = sArgs["SGLMat"] ;
00500    m_SGLThick = nArgs["SGLThick"] ;
00501 
00502    m_AGLName  = sArgs["AGLName"] ;
00503    m_AGLMat   = sArgs["AGLMat"] ;
00504    m_AGLThick = nArgs["AGLThick"] ;
00505 
00506    m_ANDName  = sArgs["ANDName"] ;
00507    m_ANDMat   = sArgs["ANDMat"] ;
00508    m_ANDThick = nArgs["ANDThick"] ;
00509 
00510    m_WebHere     = nArgs["WebHere"] ;
00511    m_WebPlName   = sArgs["WebPlName"] ;
00512    m_WebClrName  = sArgs["WebClrName"] ;
00513    m_WebPlMat    = sArgs["WebPlMat"] ;
00514    m_WebClrMat   = sArgs["WebClrMat"] ;
00515    m_vecWebPlTh  = vArgs["WebPlTh"] ;
00516    m_vecWebClrTh = vArgs["WebClrTh"] ;
00517    m_vecWebLength= vArgs["WebLength"] ;
00518 
00519    m_IlyHere     = nArgs["IlyHere"] ;
00520    m_IlyName     = sArgs["IlyName"] ;
00521    m_IlyPhiLow   = nArgs["IlyPhiLow"] ;
00522    m_IlyDelPhi   = nArgs["IlyDelPhi"] ;
00523    m_vecIlyMat   = vsArgs["IlyMat"] ;
00524    m_vecIlyThick = vArgs["IlyThick"] ;
00525 
00526    m_IlyPipeName      = sArgs["IlyPipeName"] ;
00527    m_IlyPipeHere      = nArgs["IlyPipeHere"] ;
00528    m_IlyPipeMat       = sArgs["IlyPipeMat"] ;
00529    m_IlyPipeOD        = nArgs["IlyPipeOD"] ;
00530    m_IlyPipeID        = nArgs["IlyPipeID"] ;
00531    m_vecIlyPipeLength = vArgs["IlyPipeLength"] ;
00532    m_vecIlyPipeType   = vArgs["IlyPipeType"] ;
00533    m_vecIlyPipePhi    = vArgs["IlyPipePhi"] ;
00534    m_vecIlyPipeZ      = vArgs["IlyPipeZ"] ;
00535 
00536    m_IlyPTMName   = sArgs["IlyPTMName"] ;
00537    m_IlyPTMHere   = nArgs["IlyPTMHere"] ;
00538    m_IlyPTMMat    = sArgs["IlyPTMMat"] ;
00539    m_IlyPTMWidth  = nArgs["IlyPTMWidth"] ;
00540    m_IlyPTMLength = nArgs["IlyPTMLength"] ;
00541    m_IlyPTMHeight = nArgs["IlyPTMHeight"] ;
00542    m_vecIlyPTMZ   = vArgs["IlyPTMZ"] ;
00543    m_vecIlyPTMPhi = vArgs["IlyPTMPhi"] ;
00544 
00545    m_IlyFanOutName   = sArgs["IlyFanOutName"] ;
00546    m_IlyFanOutHere   = nArgs["IlyFanOutHere"] ;
00547    m_IlyFanOutMat    = sArgs["IlyFanOutMat"] ;
00548    m_IlyFanOutWidth  = nArgs["IlyFanOutWidth"] ;
00549    m_IlyFanOutLength = nArgs["IlyFanOutLength"] ;
00550    m_IlyFanOutHeight = nArgs["IlyFanOutHeight"] ;
00551    m_vecIlyFanOutZ   = vArgs["IlyFanOutZ"] ;
00552    m_vecIlyFanOutPhi = vArgs["IlyFanOutPhi"] ;
00553    m_IlyDiffName     = sArgs["IlyDiffName"] ;
00554    m_IlyDiffMat      = sArgs["IlyDiffMat"] ;
00555    m_IlyDiffOff      = nArgs["IlyDiffOff"] ;
00556    m_IlyDiffLength   = nArgs["IlyDiffLength"] ;
00557    m_IlyBndlName     = sArgs["IlyBndlName"] ;
00558    m_IlyBndlMat      = sArgs["IlyBndlMat"] ;
00559    m_IlyBndlOff      = nArgs["IlyBndlOff"] ;
00560    m_IlyBndlLength   = nArgs["IlyBndlLength"] ;
00561    m_IlyFEMName      = sArgs["IlyFEMName"] ;
00562    m_IlyFEMMat       = sArgs["IlyFEMMat"] ;
00563    m_IlyFEMWidth     = nArgs["IlyFEMWidth"] ;
00564    m_IlyFEMLength    = nArgs["IlyFEMLength"] ;
00565    m_IlyFEMHeight    = nArgs["IlyFEMHeight"] ;
00566    m_vecIlyFEMZ      = vArgs["IlyFEMZ"] ;
00567    m_vecIlyFEMPhi    = vArgs["IlyFEMPhi"];
00568 
00569    m_HawRName   = sArgs["HawRName"] ;
00570    m_FawName    = sArgs["FawName"] ;
00571    m_FawHere    = nArgs["FawHere"] ;
00572    m_HawRHBIG   = nArgs["HawRHBIG"] ;
00573    m_HawRhsml   = nArgs["HawRhsml"] ;
00574    m_HawRCutY   = nArgs["HawRCutY"] ;
00575    m_HawRCutZ   = nArgs["HawRCutZ"] ;
00576    m_HawRCutDelY= nArgs["HawRCutDelY"] ;
00577    m_HawYOffCry = nArgs["HawYOffCry"] ;
00578 
00579    m_NFawPerSupm=  static_cast<unsigned int> ( nArgs["NFawPerSupm"] ) ;
00580    m_FawPhiOff  = nArgs["FawPhiOff"] ;
00581    m_FawDelPhi  = nArgs["FawDelPhi"] ;
00582    m_FawPhiRot  = nArgs["FawPhiRot"] ;
00583    m_FawRadOff  = nArgs["FawRadOff"] ;
00584 
00585    m_GridHere     = nArgs["GridHere"] ;
00586    m_GridName   = sArgs["GridName"]  ;
00587    m_GridMat    = sArgs["GridMat"]   ;
00588    m_GridThick  = nArgs["GridThick"] ;
00589 
00590    m_BackHere         = nArgs["BackHere"] ;
00591    m_BackXOff         = nArgs["BackXOff"] ;
00592    m_BackYOff         = nArgs["BackYOff"] ;
00593    m_BackSideName     = sArgs["BackSideName"] ;
00594    m_BackSideHere     = nArgs["BackSideHere"] ;
00595    m_BackSideLength   = nArgs["BackSideLength"] ;
00596    m_BackSideHeight   = nArgs["BackSideHeight"] ;
00597    m_BackSideWidth    = nArgs["BackSideWidth"] ;
00598    m_BackSideYOff1    = nArgs["BackSideYOff1"] ;
00599    m_BackSideYOff2    = nArgs["BackSideYOff2"] ;
00600    m_BackSideAngle    = nArgs["BackSideAngle"] ;
00601    m_BackSideMat      = sArgs["BackSideMat"] ;
00602    m_BackPlateName    = sArgs["BackPlateName"] ;
00603    m_BackPlateHere    = nArgs["BackPlateHere"] ;
00604    m_BackPlateLength  = nArgs["BackPlateLength"] ;
00605    m_BackPlateThick   = nArgs["BackPlateThick"] ;
00606    m_BackPlateWidth   = nArgs["BackPlateWidth"] ;
00607    m_BackPlateMat     = sArgs["BackPlateMat"] ;
00608    m_BackPlate2Name    = sArgs["BackPlate2Name"] ;
00609    m_BackPlate2Thick   = nArgs["BackPlate2Thick"] ;
00610    m_BackPlate2Mat     = sArgs["BackPlate2Mat"] ;
00611    m_GrilleName       = sArgs["GrilleName"] ;
00612    m_GrilleHere       = nArgs["GrilleHere"] ;
00613    m_GrilleThick      = nArgs["GrilleThick"] ;
00614    m_GrilleWidth      = nArgs["GrilleWidth"] ;
00615    m_GrilleZSpace     = nArgs["GrilleZSpace"] ;
00616    m_GrilleMat        = sArgs["GrilleMat"] ;
00617    m_vecGrilleHeight  = vArgs["GrilleHeight"] ;
00618    m_vecGrilleZOff    = vArgs["GrilleZOff"] ;
00619 
00620    m_GrEdgeSlotName     = sArgs["GrEdgeSlotName"] ;
00621    m_GrEdgeSlotMat      = sArgs["GrEdgeSlotMat"] ;
00622    m_GrEdgeSlotHere     = nArgs["GrEdgeSlotHere"] ;
00623    m_GrEdgeSlotHeight   = nArgs["GrEdgeSlotHeight"] ;
00624    m_GrEdgeSlotWidth    = nArgs["GrEdgeSlotWidth"] ;
00625    m_GrMidSlotName      = sArgs["GrMidSlotName"] ;
00626    m_GrMidSlotMat       = sArgs["GrMidSlotMat"] ;
00627    m_GrMidSlotHere      = nArgs["GrMidSlotHere"] ;
00628    m_GrMidSlotWidth     = nArgs["GrMidSlotWidth"] ;
00629    m_GrMidSlotXOff      = nArgs["GrMidSlotXOff"] ;
00630    m_vecGrMidSlotHeight = vArgs["GrMidSlotHeight"] ;
00631 
00632    m_BackPipeHere     = nArgs["BackPipeHere"] ;
00633    m_BackPipeName    = sArgs["BackPipeName"] ;
00634    m_vecBackPipeDiam = vArgs["BackPipeDiam"] ;
00635    m_vecBackPipeThick = vArgs["BackPipeThick"] ;
00636    m_BackPipeMat     = sArgs["BackPipeMat"] ;
00637    m_BackPipeWaterMat = sArgs["BackPipeWaterMat"] ;
00638 
00639 
00640    m_BackCoolHere          = nArgs["BackCoolHere"] ;
00641    m_vecBackCoolName       = vsArgs["BackCoolName"] ;
00642    m_BackCoolBarHere       = nArgs["BackCoolBarHere"] ;
00643    m_BackCoolBarWidth      = nArgs["BackCoolBarWidth"] ; 
00644    m_BackCoolBarHeight     = nArgs["BackCoolBarHeight"] ; 
00645    m_BackCoolMat           = sArgs["BackCoolMat"] ;     
00646    m_BackCoolBarName       = sArgs["BackCoolBarName"] ;      
00647    m_BackCoolBarThick      = nArgs["BackCoolBarThick"] ;  
00648    m_BackCoolBarMat        = sArgs["BackCoolBarMat"] ; 
00649    m_BackCoolBarSSName     = sArgs["BackCoolBarSSName"] ;   
00650    m_BackCoolBarSSThick    = nArgs["BackCoolBarSSThick"] ;
00651    m_BackCoolBarSSMat      = sArgs["BackCoolBarSSMat"] ;
00652    m_BackCoolBarWaName     = sArgs["BackCoolBarWaName"] ; 
00653    m_BackCoolBarWaThick    = nArgs["BackCoolBarWaThick"] ;
00654    m_BackCoolBarWaMat      = sArgs["BackCoolBarWaMat"] ;
00655    m_BackCoolVFEHere       = nArgs["BackCoolVFEHere"] ;
00656    m_BackCoolVFEName       = sArgs["BackCoolVFEName"] ; 
00657    m_BackCoolVFEMat        = sArgs["BackCoolVFEMat"] ;  
00658    m_BackVFEName           = sArgs["BackVFEName"] ;   
00659    m_BackVFEMat            = sArgs["BackVFEMat"] ;      
00660    m_vecBackVFELyrThick    = vArgs["BackVFELyrThick"] ;   
00661    m_vecBackVFELyrName     = vsArgs["BackVFELyrName"] ;
00662    m_vecBackVFELyrMat      = vsArgs["BackVFELyrMat"] ;
00663    m_vecBackCoolNSec       = vArgs["BackCoolNSec"] ; 
00664    m_vecBackCoolSecSep     = vArgs["BackCoolSecSep"] ;  
00665    m_vecBackCoolNPerSec    = vArgs["BackCoolNPerSec"] ;  
00666    m_BackCBStdSep          = nArgs["BackCBStdSep"] ;
00667 
00668    m_BackMiscHere       = nArgs["BackMiscHere"] ;
00669    m_vecBackMiscThick   = vArgs["BackMiscThick"] ;
00670    m_vecBackMiscName    = vsArgs["BackMiscName"] ;
00671    m_vecBackMiscMat     = vsArgs["BackMiscMat"] ;
00672    m_PatchPanelHere     = nArgs["PatchPanelHere"] ;
00673    m_vecPatchPanelThick = vArgs["PatchPanelThick"] ;
00674    m_vecPatchPanelNames = vsArgs["PatchPanelNames"] ;
00675    m_vecPatchPanelMat   = vsArgs["PatchPanelMat"] ;
00676    m_PatchPanelName     = sArgs["PatchPanelName"] ;
00677 
00678    m_BackCoolTankHere    = nArgs["BackCoolTankHere"] ;
00679    m_BackCoolTankName    = sArgs["BackCoolTankName"] ;
00680    m_BackCoolTankWidth   = nArgs["BackCoolTankWidth"] ;
00681    m_BackCoolTankThick   = nArgs["BackCoolTankThick"] ;
00682    m_BackCoolTankMat     = sArgs["BackCoolTankMat"] ;
00683    m_BackCoolTankWaName  = sArgs["BackCoolTankWaName"] ;
00684    m_BackCoolTankWaWidth = nArgs["BackCoolTankWaWidth"] ;
00685    m_BackCoolTankWaMat   = sArgs["BackCoolTankWaMat"] ;
00686    m_BackBracketName     = sArgs["BackBracketName"] ;
00687    m_BackBracketHeight   = nArgs["BackBracketHeight"] ;
00688    m_BackBracketMat      = sArgs["BackBracketMat"] ;
00689 
00690    m_DryAirTubeHere     = nArgs["DryAirTubeHere"] ;
00691    m_DryAirTubeName     = sArgs["DryAirTubeName"];
00692    m_MBCoolTubeNum      = static_cast<unsigned int> ( nArgs["MBCoolTubeNum"] ) ;
00693    m_DryAirTubeInnDiam  = nArgs["DryAirTubeInnDiam"];
00694    m_DryAirTubeOutDiam  = nArgs["DryAirTubeOutDiam"];
00695    m_DryAirTubeMat      = sArgs["DryAirTubeMat"];
00696    m_MBCoolTubeHere     = nArgs["MBCoolTubeHere"] ;
00697    m_MBCoolTubeName     = sArgs["MBCoolTubeName"];
00698    m_MBCoolTubeInnDiam  = nArgs["MBCoolTubeInnDiam"];
00699    m_MBCoolTubeOutDiam  = nArgs["MBCoolTubeOutDiam"];
00700    m_MBCoolTubeMat      = sArgs["MBCoolTubeMat"];
00701    m_MBManifHere        = nArgs["MBManifHere"] ;
00702    m_MBManifName        = sArgs["MBManifName"];
00703    m_MBManifInnDiam     = nArgs["MBManifInnDiam"];
00704    m_MBManifOutDiam     = nArgs["MBManifOutDiam"];
00705    m_MBManifMat         = sArgs["MBManifMat"];
00706    m_MBLyrHere          = nArgs["MBLyrHere"] ;
00707    m_vecMBLyrThick      = vArgs["MBLyrThick"];
00708    m_vecMBLyrName       = vsArgs["MBLyrName"];
00709    m_vecMBLyrMat        = vsArgs["MBLyrMat"];
00710 
00711    m_PincerRodHere      = nArgs["PincerRodHere"];
00712    m_PincerRodName      = sArgs["PincerRodName"];
00713    m_PincerRodMat       = sArgs["PincerRodMat"];
00714    m_vecPincerRodAzimuth= vArgs["PincerRodAzimuth"];
00715    m_PincerEnvName      = sArgs["PincerEnvName"];
00716    m_PincerEnvMat       = sArgs["PincerEnvMat"];
00717    m_PincerEnvWidth     = nArgs["PincerEnvWidth"];
00718    m_PincerEnvHeight    = nArgs["PincerEnvHeight"];
00719    m_PincerEnvLength    = nArgs["PincerEnvLength"];
00720    m_vecPincerEnvZOff   = vArgs["PincerEnvZOff"];
00721    m_PincerBlkName      = sArgs["PincerBlkName"];
00722    m_PincerBlkMat       = sArgs["PincerBlkMat"];
00723    m_PincerBlkLength    = nArgs["PincerBlkLength"];
00724    m_PincerShim1Name    = sArgs["PincerShim1Name"];
00725    m_PincerShimHeight   = nArgs["PincerShimHeight"];
00726    m_PincerShim2Name    = sArgs["PincerShim2Name"];
00727    m_PincerShimMat      = sArgs["PincerShimMat"];
00728    m_PincerShim1Width   = nArgs["PincerShim1Width"];
00729    m_PincerShim2Width   = nArgs["PincerShim2Width"];
00730    m_PincerCutName      = sArgs["PincerCutName"];
00731    m_PincerCutMat       = sArgs["PincerCutMat"];
00732    m_PincerCutWidth     = nArgs["PincerCutWidth"];
00733    m_PincerCutHeight    = nArgs["PincerCutHeight"];
00734 
00735    
00736    LogDebug("EcalGeom") << "DDEcalBarrelAlgo info: end initialize" ;
00737 }
00738 
00740 // DDEcalBarrelAlgo methods...
00742 
00743 void DDEcalBarrelNewAlgo::execute(DDCompactView& cpv) 
00744 {
00745    LogDebug("EcalGeom") << "******** DDEcalBarrelAlgo execute!" << std::endl ;
00746 
00747    if( barHere() != 0 )
00748    {
00749       const unsigned int copyOne (1) ;
00750       const unsigned int copyTwo (2) ;
00751       // Barrel parent volume----------------------------------------------------------
00752       cpv.position( DDLogicalPart( barName(), barMat(), 
00753                             DDSolidFactory::polycone(
00754                                barName(), barPhiLo(), ( barPhiHi() - barPhiLo() ), 
00755                                vecBarZPts(), vecBarRMin(), vecBarRMax())),
00756              parent().name() , 
00757              copyOne, 
00758              DDTranslation(vecBarTran()[0],
00759                            vecBarTran()[1],
00760                            vecBarTran()[2]), 
00761              myrot(barName().name()+"Rot",
00762                    Rota(Vec3(vecBarRota3()[0],
00763                              vecBarRota3()[1],
00764                              vecBarRota3()[2]),
00765                         vecBarRota3()[3])*
00766                    Rota(Vec3(vecBarRota2()[0],
00767                              vecBarRota2()[1],
00768                              vecBarRota2()[2]),
00769                         vecBarRota2()[3])*
00770                    Rota(Vec3(vecBarRota()[0],
00771                              vecBarRota()[1],
00772                              vecBarRota()[2]),
00773                         vecBarRota()[3]) ) ) ;
00774       // End Barrel parent volume----------------------------------------------------------
00775 
00776 
00777       // Supermodule parent------------------------------------------------------------
00778 
00779       const DDName spmcut1ddname ( ( 0 != spmCutShow() ) ?
00780                                    spmName() : ddname( m_SpmName + "CUT1" ) ) ;
00781       const DDSolid ddspm ( DDSolidFactory::polycone(
00782                                spmcut1ddname,
00783                                spmLowPhi(),  spmDelPhi(),
00784                                vecSpmZPts(), vecSpmRMin(), vecSpmRMax())) ;
00785 
00786       const unsigned int indx ( vecSpmRMax().size()/2 ) ;
00787 
00788 
00789       // Deal with the cut boxes first
00790       const DDSolid spmCutBox ( DDSolidFactory::box(
00791                                    spmCutName(), 
00792                                    1.05*(vecSpmRMax()[indx] - vecSpmRMin()[indx])/2.,  
00793                                    spmCutThick()/2.,
00794                                    fabs( vecSpmZPts().back() - vecSpmZPts().front() )/2.+1*mm) ) ;
00795       const std::vector<double>& cutBoxParms ( spmCutBox.parameters() ) ;
00796       const DDLogicalPart spmCutLog ( spmCutName(), spmMat(), spmCutBox ) ;
00797 
00798       // Now the expansion box
00799       const double xExp ( spmExpThick()/2. ) ;
00800       const double yExp ( spmExpWide()/2. ) ;
00801       const double zExp ( fabs( vecSpmZPts().back() -
00802                                 vecSpmZPts().front() )/2.) ;
00803       const DDName expName ( m_SpmName + "EXP" ) ;
00804       const DDSolid spmExpBox ( DDSolidFactory::box(
00805                                    expName , 
00806                                    xExp    ,  
00807                                    yExp    ,
00808                                    zExp     )) ;
00809       const DDTranslation expTra ( vecSpmRMax().back() - xExp, spmExpYOff(),
00810                                    vecSpmZPts().front() + zExp ) ;
00811       const DDLogicalPart expLog ( expName, spmMat(), spmExpBox ) ;
00812 
00813 /*      const DDName unionName ( ddname( m_SpmName + "UNI" ) ) ;
00814       if( 0 != spmCutShow() )
00815       {
00816          cpv.position( expLog, spmName(), copyOne, expTra, DDRotation() ) ;
00817       }
00818       else
00819       {
00820          const DDSolid unionSolid ( DDSolidFactory::unionSolid(
00821                                        unionName,
00822                                        spmcut1ddname, expName,
00823                                        expTra, DDRotation() ) ) ;
00824                                        }*/
00825 
00826 
00827       // Supermodule side platess
00828       const DDSolid sideSolid ( DDSolidFactory::box(
00829                                    spmSideName(), 
00830                                    spmSideHigh()/2.,  
00831                                    spmSideThick()/2.,
00832                                    fabs( vecSpmZPts()[1] - vecSpmZPts()[0] )/2.) ) ;
00833       const std::vector<double>& sideParms ( sideSolid.parameters() ) ;
00834       const DDLogicalPart sideLog ( spmSideName(), spmSideMat(), sideSolid ) ;
00835       
00836       DDSolid temp1 ;
00837       DDSolid temp2 ;
00838       for( unsigned int icopy(1); icopy <= 2; ++icopy )
00839       {
00840          const std::vector<double>& tvec ( 1==icopy ? vecSpmCutTM() : vecSpmCutTP() ) ;
00841          const double rang               ( 1==icopy ? spmCutRM() : spmCutRP() ) ;
00842          
00843          const Tl3D tr ( tvec[0], tvec[1], tvec[2] );
00844          const RoZ3D   ro ( rang ) ;
00845          const Tf3D alltrot (
00846             RoZ3D( 1==icopy ? spmLowPhi() : spmLowPhi()+spmDelPhi() )*
00847             Tl3D( ( vecSpmRMax()[indx]+vecSpmRMin()[indx])/2.,
00848                   0,
00849                   (vecSpmZPts().front()+ vecSpmZPts().back())/2.)*
00850             tr*ro) ;
00851 
00852          const DDRotation    ddrot ( myrot(spmCutName().name() + 
00853                                            dbl_to_string(icopy),
00854                                            alltrot.getRotation() ) ) ;
00855          const DDTranslation ddtra ( alltrot.getTranslation() ) ;
00856 
00857          
00858          const Tl3D trSide ( tvec[0], 
00859                              tvec[1] + ( 1==icopy ? 1. : -1. )*( cutBoxParms[1]+sideParms[1] )
00860                              + ( 1==icopy ? spmSideYOffM() : spmSideYOffP() ), 
00861                              tvec[2] );
00862          const RoZ3D   roSide ( rang ) ;
00863          const Tf3D sideRot (
00864             RoZ3D( 1==icopy ? spmLowPhi() : spmLowPhi()+spmDelPhi() )*
00865             Tl3D( vecSpmRMin().front() + sideParms[0] ,
00866                   0,
00867                   vecSpmZPts().front()+ sideParms[2] )*
00868             trSide*roSide) ;
00869 
00870          const DDRotation    sideddrot ( myrot(spmSideName().name() + 
00871                                                dbl_to_string(icopy),
00872                                                sideRot.getRotation() ) ) ;
00873          const DDTranslation sideddtra ( sideRot.getTranslation() ) ;
00874 
00875          cpv.position( sideLog,
00876                 spmName(), 
00877                 icopy, 
00878                 sideddtra,
00879                 sideddrot ) ;
00880 
00881 
00882          if( 0 != spmCutShow() ) // do this if we are "showing" the boxes
00883          {
00884             cpv.position( spmCutLog,
00885                    spmName(), 
00886                    icopy, 
00887                    ddtra,
00888                    ddrot ) ;
00889          }
00890          else // do this if we are subtracting the boxes
00891          {
00892             if( 1 == icopy )
00893             {
00894                temp1 = DDSolidFactory::subtraction( DDName( m_SpmName+"_T1" ),
00895                                                     spmcut1ddname, spmCutBox,
00896                                                     ddtra, ddrot ) ;
00897             }
00898             else
00899             {
00900                temp2 = DDSolidFactory::subtraction( spmName(),
00901                                                     temp1, spmCutBox,
00902                                                     ddtra, ddrot ) ;
00903             }
00904          }
00905       }
00906 
00907       const DDLogicalPart spmLog (spmName(), spmMat(), 
00908                                   ((0 != spmCutShow()) ? ddspm : temp2)  ) ;
00909 
00910       const double dphi ( 360.*deg/(1.*spmNPerHalf() ) ) ;
00911       for( unsigned int iphi (0); iphi<2*spmNPerHalf() ; ++iphi ) 
00912       {
00913          const double phi ( iphi*dphi + spmPhiOff() ) ; //- 0.000130/deg ) ;
00914 
00915          // this base rotation includes the base translation & rotation
00916          // plus flipping for the negative z hemisphere, plus
00917          // the phi rotation for this module
00918          const Tf3D rotaBase ( RoZ3D( phi )*
00919                                ( iphi < spmNPerHalf() ? Ro3D() :
00920                                  RoX3D( 180.*deg ) )*
00921                                Ro3D( vecSpmBRota()[3],
00922                                      Vec3( vecSpmBRota()[0],
00923                                            vecSpmBRota()[1],
00924                                            vecSpmBRota()[2]))*
00925                                Tl3D( Vec3( vecSpmBTran()[0],
00926                                            vecSpmBTran()[1],
00927                                            vecSpmBTran()[2] ))) ;
00928 
00929          // here the individual rotations & translations of the supermodule
00930          // are implemented on top of the overall "base" rotation & translation
00931 
00932          const unsigned int offr ( 4*iphi ) ;
00933          const unsigned int offt ( 3*iphi ) ;
00934 
00935          const Ro3D r1 ( vecSpmRota()[     offr+3], 
00936                          Vec3(vecSpmRota()[offr+0],
00937                               vecSpmRota()[offr+1],
00938                               vecSpmRota()[offr+2]  ) ) ;
00939 
00940          const Tf3D rotaExtra ( r1*Tl3D( Vec3(vecSpmTran()[offt+0],
00941                                               vecSpmTran()[offt+1],
00942                                               vecSpmTran()[offt+2]  ) ) ) ;
00943 
00944          const Tf3D both ( rotaExtra*rotaBase ) ;
00945 
00946          const DDRotation rota ( myrot( spmName().name()+dbl_to_string(phi/deg), 
00947                                         both.getRotation() ) );
00948 
00949          if( vecSpmHere()[iphi] != 0 )
00950          {
00951            // convert from CLHEP to DDTranslation & etc. -- Michael Case
00952            DDTranslation myTran(both.getTranslation().x(), both.getTranslation().y(), both.getTranslation().z());
00953             cpv.position( spmLog,
00954                    barName(), 
00955                    iphi+1, 
00956                    myTran,
00957                    rota                     ) ;
00958          }
00959       } 
00960       // End Supermodule parent------------------------------------------------------------
00961 
00962       // Begin Inner Layer volumes---------------------------------------------------------
00963       const double  ilyLength  ( vecSpmZPts()[1] - vecSpmZPts()[0] ) ;
00964       double        ilyRMin    ( vecSpmRMin()[0] ) ;
00965       double        ilyThick   ( 0 ) ;
00966       for( unsigned int ilyx ( 0 ) ; ilyx != vecIlyThick().size() ; ++ilyx )
00967       {
00968          ilyThick += vecIlyThick()[ilyx] ;
00969       }
00970       const DDName        ilyDDName  ( ddname( ilyName() ) ) ;
00971       const DDSolid       ilySolid   ( DDSolidFactory::tubs( ilyDDName,
00972                                                              ilyLength/2,
00973                                                              ilyRMin,
00974                                                              ilyRMin + ilyThick,
00975                                                              ilyPhiLow(),
00976                                                              ilyDelPhi() ) ) ;
00977       const DDLogicalPart ilyLog     ( ilyDDName, spmMat(), ilySolid ) ;
00978       cpv.position( ilyLog,
00979              spmLog, 
00980              copyOne, 
00981              DDTranslation(0,0, ilyLength/2 ),
00982              DDRotation() ) ;
00983 
00984       DDLogicalPart ilyPipeLog[200] ;
00985 
00986       if( 0 != ilyPipeHere() )
00987       {
00988          for( unsigned int iPipeType ( 0 ) ; iPipeType != vecIlyPipeLength().size(); ++iPipeType )
00989          {
00990             const DDName pName ( ddname( ilyPipeName() + "_" + 
00991                                          int_to_string(iPipeType+1) ) ) ;
00992          
00993             DDSolid ilyPipeSolid ( DDSolidFactory::tubs( pName ,
00994                                                          vecIlyPipeLength()[iPipeType]/2.,
00995                                                          0,
00996                                                          ilyPipeOD()/2,
00997                                                          0*deg, 360*deg ) ) ;
00998             ilyPipeLog[iPipeType] = DDLogicalPart( pName, ilyPipeMat(), ilyPipeSolid ) ;
00999                   
01000             const DDName pWaName ( ddname( ilyPipeName() + "Wa_" + 
01001                                            int_to_string(iPipeType+1) ) ) ;
01002             DDSolid ilyPipeWaSolid ( DDSolidFactory::tubs( pWaName ,
01003                                                            vecIlyPipeLength()[iPipeType]/2.,
01004                                                            0, 
01005                                                            ilyPipeID()/2,
01006                                                            0*deg, 360*deg ) ) ;
01007             const DDLogicalPart ilyPipeWaLog ( pWaName, backPipeWaterMat(), ilyPipeWaSolid ) ;
01008 
01009             cpv.position( ilyPipeWaLog,
01010                    pName, 
01011                    copyOne, 
01012                    DDTranslation(0,0,0),
01013                    DDRotation() ) ;
01014          }
01015       } 
01016 
01017       DDSolid ilyPTMSolid ( DDSolidFactory::box( ilyPTMName(), 
01018                                                  ilyPTMHeight()/2.,
01019                                                  ilyPTMWidth()/2.,  
01020                                                  ilyPTMLength()/2.   ) ) ;
01021       const DDLogicalPart ilyPTMLog ( ilyPTMName(),
01022                                       ilyPTMMat(),
01023                                       ilyPTMSolid ) ;
01024 
01025       DDSolid ilyFanOutSolid ( DDSolidFactory::box( ilyFanOutName(), 
01026                                                     ilyFanOutHeight()/2.,
01027                                                     ilyFanOutWidth()/2.,  
01028                                                     ilyFanOutLength()/2.   ) ) ;
01029       const DDLogicalPart ilyFanOutLog ( ilyFanOutName(),
01030                                          ilyFanOutMat(),
01031                                          ilyFanOutSolid ) ;
01032 
01033       DDSolid ilyFEMSolid ( DDSolidFactory::box( ilyFEMName(), 
01034                                                  ilyFEMHeight()/2.,
01035                                                  ilyFEMWidth()/2.,  
01036                                                  ilyFEMLength()/2.   ) ) ;
01037       const DDLogicalPart ilyFEMLog ( ilyFEMName(),
01038                                       ilyFEMMat(),
01039                                       ilyFEMSolid ) ;
01040 
01041       DDSolid ilyDiffSolid ( DDSolidFactory::box( ilyDiffName(), 
01042                                                   ilyFanOutHeight()/2.,
01043                                                   ilyFanOutWidth()/2.,  
01044                                                   ilyDiffLength()/2.   ) ) ;
01045       const DDLogicalPart ilyDiffLog ( ilyDiffName(),
01046                                        ilyDiffMat(),
01047                                        ilyDiffSolid ) ;
01048 
01049       DDSolid ilyBndlSolid ( DDSolidFactory::box( ilyBndlName(), 
01050                                                   ilyFanOutHeight()/2.,
01051                                                   ilyFanOutWidth()/2.,  
01052                                                   ilyBndlLength()/2.   ) ) ;
01053       const DDLogicalPart ilyBndlLog ( ilyBndlName(),
01054                                        ilyBndlMat(),
01055                                        ilyBndlSolid ) ;
01056       cpv.position( ilyDiffLog,
01057              ilyFanOutName(), 
01058              copyOne, 
01059              DDTranslation(0,0, -ilyFanOutLength()/2 + ilyDiffLength()/2 + ilyDiffOff() ),
01060              DDRotation() ) ;
01061       cpv.position( ilyBndlLog,
01062              ilyFanOutName(), 
01063              copyOne, 
01064              DDTranslation(0,0, -ilyFanOutLength()/2 + ilyBndlLength()/2 + ilyBndlOff() ),
01065              DDRotation() ) ;
01066 
01067       for( unsigned int ily ( 0 ) ; ily != vecIlyThick().size() ; ++ily )
01068       {
01069          const double        ilyRMax     ( ilyRMin + vecIlyThick()[ily] ) ;
01070          const DDName        xilyName    ( ddname( ilyName() + int_to_string(ily) ) ) ;
01071          const DDSolid       xilySolid   ( DDSolidFactory::tubs( xilyName,
01072                                                                  ilyLength/2,
01073                                                                  ilyRMin,
01074                                                                  ilyRMax,
01075                                                                  ilyPhiLow(),
01076                                                                  ilyDelPhi() ) ) ;
01077 
01078          const DDLogicalPart xilyLog     ( xilyName, ddmat(vecIlyMat()[ily]), xilySolid ) ;
01079 
01080          if( 0 != ilyHere() )
01081          {
01082             cpv.position( xilyLog,
01083                    ilyLog, 
01084                    copyOne, 
01085                    DDTranslation(0,0,0),
01086                    DDRotation() ) ;
01087 
01088             unsigned int copyNum[] = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0} ;
01089 
01090             if( 10*mm <  vecIlyThick()[ily] &&
01091                 vecIlyThick().size() != (ily+1) &&
01092                 0     != ilyPipeHere()         )
01093             {
01094                if( 0 != ilyPTMHere() )
01095                {
01096                   unsigned int ptmCopy ( 0 ) ;
01097                   for( unsigned int ilyPTM ( 0 ) ; ilyPTM != vecIlyPTMZ().size() ; ++ilyPTM )
01098                   {
01099                      const double radius ( ilyRMax - 1*mm - ilyPTMHeight()/2. ) ;
01100                      const double phi    ( vecIlyPTMPhi()[ilyPTM] ) ;
01101                      const double yy     ( radius*sin(phi) ) ;
01102                      const double xx     ( radius*cos(phi) ) ;
01103                      ++ptmCopy ; 
01104                      cpv.position( ilyPTMLog,
01105                             xilyLog, 
01106                             ptmCopy, 
01107                             DDTranslation(xx,yy, vecIlyPTMZ()[ilyPTM] -ilyLength/2 ),
01108                             myrot( ilyPTMLog.name().name() + "_rot" +
01109                                    int_to_string( ptmCopy ) , CLHEP::HepRotationZ( phi ) )) ;
01110                   }
01111                }
01112                if( 0 != ilyFanOutHere() )
01113                {
01114                   unsigned int fanOutCopy ( 0 ) ;
01115                   for( unsigned int ilyFO ( 0 ) ; ilyFO != vecIlyFanOutZ().size() ; ++ilyFO )
01116                   {
01117                      const double radius ( ilyRMax - 1*mm - ilyFanOutHeight()/2. ) ;
01118                      const double phi    ( vecIlyFanOutPhi()[ilyFO] ) ;
01119                      const double yy     ( radius*sin(phi) ) ;
01120                      const double xx     ( radius*cos(phi) ) ;
01121                      ++fanOutCopy ; 
01122                      cpv.position( ilyFanOutLog,
01123                             xilyLog, 
01124                             fanOutCopy, 
01125                             DDTranslation(xx,yy, vecIlyFanOutZ()[ilyFO] -ilyLength/2 ),
01126                             myrot( ilyFanOutLog.name().name() + "_rot" +
01127                                    int_to_string( fanOutCopy ) , 
01128                                    CLHEP::HepRotationZ( phi )*CLHEP::HepRotationY( 180*deg ) )) ;
01129                   }
01130                   unsigned int femCopy ( 0 ) ;
01131                   for( unsigned int ilyFEM ( 0 ) ; ilyFEM != vecIlyFEMZ().size() ; ++ilyFEM )
01132                   {
01133                      const double radius ( ilyRMax - 1*mm - ilyFEMHeight()/2. ) ;
01134                      const double phi    ( vecIlyFEMPhi()[ilyFEM] ) ;
01135                      const double yy     ( radius*sin(phi) ) ;
01136                      const double xx     ( radius*cos(phi) ) ;
01137                      ++femCopy ; 
01138                      cpv.position( ilyFEMLog,
01139                             xilyLog, 
01140                             femCopy, 
01141                             DDTranslation(xx,yy, vecIlyFEMZ()[ilyFEM] -ilyLength/2 ),
01142                             myrot( ilyFEMLog.name().name() + "_rot" +
01143                                    int_to_string( femCopy ) , CLHEP::HepRotationZ( phi ) )) ;
01144                   }
01145                }
01146                for( unsigned int iPipe ( 0 ) ; iPipe != vecIlyPipePhi().size(); ++iPipe )
01147                {
01148                   const unsigned int type ( static_cast<unsigned int> ( round( vecIlyPipeType()[iPipe] ) ) ) ;
01149 //                std::cout<<" iPipe, type= " << iPipe << ", " << type << std::endl ;
01150                   const double       zz   ( -ilyLength/2 + vecIlyPipeZ()[iPipe] +
01151                                             ( 9>type ? vecIlyPipeLength()[type]/2. : 0 ) ) ;
01152 
01153                   for( unsigned int ly ( 0 ) ; ly != 2 ; ++ly )
01154                   {
01155                      const double radius ( 0 == ly ? ilyRMin + ilyPipeOD()/2. + 1*mm :
01156                                            ilyRMax - ilyPipeOD()/2. - 1*mm  ) ;
01157                      const double phi    ( vecIlyPipePhi()[iPipe] ) ;
01158                      const double yy     ( radius*sin(phi) ) ;
01159                      const double xx     ( radius*cos(phi) ) ;
01160                      ++copyNum[type],
01161                      cpv.position( ilyPipeLog[type],
01162                             xilyLog, 
01163                             copyNum[type],
01164                             DDTranslation(xx,yy,zz),
01165                             ( 9 > type ? DDRotation() :
01166                               myrot( ilyPipeLog[type].name().name() + "_rot" +
01167                                      int_to_string( copyNum[type] ) , Rota( Vec3(xx,yy,0), 90*deg) ) ) ) ;
01168                   }
01169                }
01170             }
01171          }
01172          ilyRMin = ilyRMax ;
01173       }      
01174       // End Inner Layer volumes---------------------------------------------------------
01175 
01176       const DDName clyrName ( DDName( "ECLYR" ) ) ;
01177       std::vector<double> cri;
01178       std::vector<double> cro;
01179       std::vector<double> czz;
01180       czz.push_back( vecSpmZPts()[1] ) ;
01181       cri.push_back( vecSpmRMin()[0] ) ;
01182       cro.push_back( vecSpmRMin()[0] + 25*mm ) ;
01183       czz.push_back( vecSpmZPts()[2] ) ;
01184       cri.push_back( vecSpmRMin()[2] ) ;
01185       cro.push_back( vecSpmRMin()[2] + 10*mm ) ;
01186       const DDSolid clyrSolid ( DDSolidFactory::polycone( clyrName, -9.5*deg,  19*deg, czz,cri,cro) ) ;
01187       const DDLogicalPart clyrLog ( clyrName, ddmat(vecIlyMat()[4]), clyrSolid ) ;
01188       cpv.position( clyrLog, spmLog, copyOne, DDTranslation(0,0,0), DDRotation() ) ;
01189 
01190       // Begin Alveolar Wedge parent ------------------------------------------------------
01191 //----------------
01192 
01193       // the next few lines accumulate dimensions appropriate to crystal type 1
01194       // which we use to set some of the features of the half-alveolar wedge (hawR).
01195 
01196 //      const double ANom1 ( vecNomCryDimAR()[0] ) ;
01197       const double BNom1 ( vecNomCryDimCR()[0] ) ;
01198       const double bNom1 ( vecNomCryDimCF()[0] ) ;
01199 //      const double HNom1 ( vecNomCryDimBR()[0] ) ;
01200 //      const double hNom1 ( vecNomCryDimBF()[0] ) ;
01201       const double sWall1( wallThAlv() ) ;
01202       const double fWall1( wallFrAlv() ) ;
01203 //      const double rWall1( wallReAlv() ) ;
01204       const double sWrap1( wrapThAlv() ) ;
01205       const double fWrap1( wrapFrAlv() ) ;
01206 //      const double rWrap1( wrapReAlv() ) ;
01207       const double sClr1 ( clrThAlv() ) ;
01208       const double fClr1 ( clrFrAlv() ) ;
01209 //      const double rClr1 ( clrReAlv() ) ;
01210       const double LNom1 ( nomCryDimLZ() ) ;
01211       const double beta1      ( atan( ( BNom1 - bNom1 )/LNom1 ) ) ;
01212 //      const double cosbeta1   ( cos( beta1 ) ) ;
01213       const double sinbeta1   ( sin( beta1 ) ) ;
01214 
01215       const double tana_hawR ( ( BNom1 - bNom1 )/LNom1 ) ;
01216 
01217       const double H_hawR ( hawRHBIG() ) ;
01218       const double h_hawR ( hawRhsml() ) ;
01219       const double a_hawR ( bNom1 + sClr1 + 2*sWrap1 + 2*sWall1
01220                             - sinbeta1*( fClr1 + fWrap1 + fWall1 ) ) ;
01221       const double B_hawR ( a_hawR + H_hawR*tana_hawR ) ;
01222       const double b_hawR ( a_hawR + h_hawR*tana_hawR ) ;
01223       const double L_hawR ( vecSpmZPts()[2] ) ;
01224 
01225       const Trap trapHAWR (
01226          a_hawR/2.,           //double aHalfLengthXNegZLoY , // bl1, A/2
01227          a_hawR/2.,           //double aHalfLengthXPosZLoY , // bl2, a/2
01228          b_hawR/2.,           //double aHalfLengthXPosZHiY , // tl2, b/2
01229          H_hawR/2.,           //double aHalfLengthYNegZ    , // h1, H/2
01230          h_hawR/2.,           //double aHalfLengthYPosZ    , // h2, h/2
01231          L_hawR/2.,           //double aHalfLengthZ        , // dz,  L/2
01232          90*deg,              //double aAngleAD            , // alfa1
01233          0,                   //double aCoord15X           , // x15
01234          0                    //double aCoord15Y             // y15
01235          ) ;
01236 
01237       const DDName        hawRName1  ( ddname( hawRName().name() + "1") ) ;
01238       const DDSolid       hawRSolid1 ( mytrap(hawRName1.name(), trapHAWR ) ) ;
01239       const DDLogicalPart hawRLog1   ( hawRName1, spmMat(), hawRSolid1 ) ;
01240 
01241       const double al1_fawR ( atan( ( B_hawR - a_hawR )/H_hawR ) + M_PI_2 ) ;
01242 
01243       // here is trap for Full Alveolar Wedge
01244       const Trap trapFAW (
01245          a_hawR,           //double aHalfLengthXNegZLoY , // bl1, A/2
01246          a_hawR,           //double aHalfLengthXPosZLoY , // bl2, a/2
01247          b_hawR,           //double aHalfLengthXPosZHiY , // tl2, b/2
01248          H_hawR/2.,        //double aHalfLengthYNegZ    , // h1, H/2
01249          h_hawR/2.,        //double aHalfLengthYPosZ    , // h2, h/2
01250          L_hawR/2.,        //double aHalfLengthZ        , // dz,  L/2
01251          al1_fawR,         //double aAngleAD            , // alfa1
01252          0,                //double aCoord15X           , // x15
01253          0                 //double aCoord15Y             // y15
01254          ) ;
01255 
01256       const DDName        fawName1  ( ddname( fawName().name() + "1") ) ;
01257       const DDSolid       fawSolid1 ( mytrap( fawName1.name(), trapFAW ) ) ;
01258       const DDLogicalPart fawLog1   ( fawName1, spmMat(), fawSolid1 ) ;
01259 
01260       const Trap::VertexList vHAW ( trapHAWR.vertexList() ) ;
01261       const Trap::VertexList vFAW ( trapFAW.vertexList() ) ;
01262 
01263       const double hawBoxClr ( 1*mm ) ;
01264 
01265       // HAW cut box to cut off back end of wedge
01266       const DDName  hawCutName ( ddname( hawRName().name() + "CUTBOX" ) ) ;
01267       const DDSolid hawCutBox  ( DDSolidFactory::box(
01268                                     hawCutName, 
01269                                     b_hawR/2 + hawBoxClr,  
01270                                     hawRCutY()/2,
01271                                     hawRCutZ()/2 ) ) ;
01272       const std::vector<double>& hawBoxParms ( hawCutBox.parameters() ) ;
01273       const DDLogicalPart hawCutLog ( hawCutName, spmMat(), hawCutBox ) ;
01274       
01275       const Pt3D b1 (  hawBoxParms[0],  hawBoxParms[1],  hawBoxParms[2] ) ;
01276       const Pt3D b2 ( -hawBoxParms[0],  hawBoxParms[1],  hawBoxParms[2] ) ;
01277       const Pt3D b3 ( -hawBoxParms[0],  hawBoxParms[1], -hawBoxParms[2] ) ;
01278 
01279       const double zDel ( sqrt( 4*hawBoxParms[2]*hawBoxParms[2] 
01280                                 -(h_hawR-hawRCutDelY())*(h_hawR-hawRCutDelY())  ) ) ;
01281 
01282       const Tf3D hawCutForm ( 
01283          b1, b2, b3,
01284          vHAW[2]    + Pt3D( hawBoxClr, -hawRCutDelY(), 0), 
01285          vHAW[1]    + Pt3D(-hawBoxClr, -hawRCutDelY(), 0),
01286          Pt3D( vHAW[0].x() -hawBoxClr, vHAW[0].y(), vHAW[0].z() - zDel  ) ) ;
01287 
01288       const DDSolid       hawRSolid ( DDSolidFactory::subtraction(
01289                                          hawRName(),
01290                                          hawRSolid1, hawCutBox,
01291                                          DDTranslation(hawCutForm.getTranslation().x(), hawCutForm.getTranslation().y(), hawCutForm.getTranslation().z()),
01292                                          myrot( hawCutName.name()+"R",
01293                                                 hawCutForm.getRotation() ) ) ) ;
01294       const DDLogicalPart hawRLog   ( hawRName(), spmMat(), hawRSolid ) ;
01295 
01296       // FAW cut box to cut off back end of wedge
01297       const DDName  fawCutName ( ddname( fawName().name() + "CUTBOX") ) ;
01298       const DDSolid fawCutBox  ( DDSolidFactory::box(
01299                                     fawCutName, 
01300                                     2*hawBoxParms[0],  
01301                                     hawBoxParms[1],
01302                                     hawBoxParms[2] ) ) ;
01303 
01304       const std::vector<double>& fawBoxParms ( fawCutBox.parameters() ) ;
01305       const DDLogicalPart fawCutLog ( fawCutName, spmMat(), fawCutBox ) ;
01306       
01307       const Pt3D bb1 (  fawBoxParms[0],  fawBoxParms[1],  fawBoxParms[2] ) ;
01308       const Pt3D bb2 ( -fawBoxParms[0],  fawBoxParms[1],  fawBoxParms[2] ) ;
01309       const Pt3D bb3 ( -fawBoxParms[0],  fawBoxParms[1], -fawBoxParms[2] ) ;
01310 
01311       const Tf3D fawCutForm ( 
01312          bb1, bb2, bb3,
01313          vFAW[2]   + Pt3D( 2*hawBoxClr,-5*mm,0), 
01314          vFAW[1]   + Pt3D(-2*hawBoxClr,-5*mm,0),
01315          Pt3D( vFAW[1].x()-2*hawBoxClr, vFAW[1].y()-trapFAW.h(), vFAW[1].z() - zDel ) ) ;
01316 
01317       const DDSolid       fawSolid ( DDSolidFactory::subtraction(
01318                                          fawName(),
01319                                          fawSolid1, fawCutBox,
01320                                          DDTranslation(fawCutForm.getTranslation().x(), fawCutForm.getTranslation().y(), fawCutForm.getTranslation().z()) ,
01321                                          myrot( fawCutName.name()+"R",
01322                                                 fawCutForm.getRotation() ) ) ) ;
01323       const DDLogicalPart fawLog   ( fawName(), spmMat(), fawSolid ) ;
01324 
01325 
01326       const Tf3D hawRform ( vHAW[3], vHAW[0], vHAW[1], // HAW inside FAW
01327                             vFAW[3], 0.5*(vFAW[0]+vFAW[3]), 0.5*(vFAW[1]+vFAW[2] ) ) ;
01328       cpv.position( hawRLog,
01329              fawLog, 
01330              copyOne, 
01331              DDTranslation(hawRform.getTranslation().x(), hawRform.getTranslation().y(), hawRform.getTranslation().z()),
01332              myrot( hawRName().name()+"R", 
01333                     hawRform.getRotation() ) ) ;
01334 
01335       cpv.position( hawRLog,
01336              fawLog, 
01337              copyTwo, 
01338              DDTranslation( -hawRform.getTranslation().x(),
01339                             -hawRform.getTranslation().y(),
01340                             -hawRform.getTranslation().z() ),
01341              myrot( hawRName().name()+"RotRefl",
01342                     CLHEP::HepRotationY(180*deg)*                 // rotate about Y after refl thru Z
01343                     CLHEP::HepRep3x3(1,0,0, 0,1,0, 0,0,-1) ) ) ;
01344 
01345 /* this for display of haw cut box instead of subtraction
01346       cpv.position( hawCutLog,
01347              hawRName, 
01348              copyOne, 
01349              hawCutForm.getTranslation(),
01350              myrot( hawCutName.name()+"R", 
01351                     hawCutForm.getRotation() )   ) ;
01352 */
01353 
01354       for( unsigned int iPhi ( 1 ); iPhi <= nFawPerSupm() ; ++iPhi )
01355       {
01356          const double rPhi ( fawPhiOff() + ( iPhi - 0.5 )*fawDelPhi() ) ;
01357 
01358          const Tf3D fawform ( RoZ3D( rPhi )*
01359                               Tl3D( fawRadOff() + ( trapFAW.H() + trapFAW.h() )/4 ,
01360                                     0, 
01361                                     trapFAW.L()/2 )*
01362                               RoZ3D( -90*deg + fawPhiRot() ) ) ;
01363          if( fawHere() )
01364             cpv.position( fawLog,
01365                    spmLog, 
01366                    iPhi, 
01367                    DDTranslation(fawform.getTranslation().x(), fawform.getTranslation().y(), fawform.getTranslation().z() ),
01368                    myrot( fawName().name()+"_Rot" + int_to_string(iPhi), 
01369                           fawform.getRotation() ) ) ;
01370       }
01371 
01372       // End Alveolar Wedge parent ------------------------------------------------------
01373 
01374       // Begin Grid + Tablet insertion
01375 
01376       const double h_Grid ( gridThick() ) ;
01377 
01378       const Trap trapGrid (
01379          ( B_hawR - h_Grid*( B_hawR - a_hawR )/H_hawR )/2, // bl1, A/2
01380          ( b_hawR - h_Grid*( B_hawR - a_hawR )/H_hawR )/2, // bl2, a/2
01381          b_hawR/2., // tl2, b/2
01382          h_Grid/2., // h1, H/2
01383          h_Grid/2., // h2, h/2
01384          (L_hawR-8*cm)/2., // dz,  L/2
01385          90*deg,    // alfa1
01386          0,         // x15
01387          H_hawR - h_hawR // y15
01388          ) ;
01389 
01390       const DDSolid       gridSolid ( mytrap( gridName().name(), trapGrid ) ) ;
01391       const DDLogicalPart gridLog   ( gridName(), gridMat(), gridSolid ) ;
01392 
01393       const Trap::VertexList vGrid ( trapGrid.vertexList() ) ;
01394 
01395       const Tf3D gridForm ( vGrid[4],                   vGrid[5], vGrid[6], // Grid inside HAW
01396                             vHAW[5] - Pt3D(0,h_Grid,0),  vHAW[5],  vHAW[6]   ) ;
01397 
01398       if( 0 != gridHere() )
01399          cpv.position( gridLog,
01400                 hawRLog, 
01401                 copyOne, 
01402                 DDTranslation(gridForm.getTranslation().x(), gridForm.getTranslation().y(), gridForm.getTranslation().z() ),
01403                 myrot( gridName().name()+"R", 
01404                        gridForm.getRotation() ) ) ;
01405 
01406       // End Grid + Tablet insertion
01407 
01408       // begin filling Wedge with crystal plus supports --------------------------
01409 
01410       const double aNom ( nomCryDimAF() ) ;
01411       const double LNom ( nomCryDimLZ() ) ;
01412 
01413       const double AUnd ( underAR() ) ;
01414       const double aUnd ( underAF() ) ;
01415 //      const double BUnd ( underCR() ) ;
01416       const double bUnd ( underCF() ) ;
01417       const double HUnd ( underBR() ) ;
01418       const double hUnd ( underBF() ) ;
01419       const double LUnd ( underLZ() ) ;
01420 
01421       const double sWall ( wallThAlv() ) ;
01422       const double sWrap ( wrapThAlv() ) ;
01423       const double sClr  ( clrThAlv() ) ;
01424 
01425       const double fWall ( wallFrAlv() ) ;
01426       const double fWrap ( wrapFrAlv() ) ;
01427       const double fClr  ( clrFrAlv() ) ;
01428 
01429       const double rWall ( wallReAlv() ) ;
01430       const double rWrap ( wrapReAlv() ) ;
01431       const double rClr  ( clrReAlv() ) ;
01432       
01433       // theta is angle in yz plane between z axis & leading edge of crystal
01434       double theta ( 90*deg ) ;
01435       double zee   ( 0*mm ) ;
01436       double side  ( 0*mm ) ;
01437       double zeta  ( 0*deg ) ; // increment in theta for last crystal
01438 
01439       for( unsigned int cryType ( 1 ) ; cryType <= nCryTypes() ; ++cryType )
01440       {
01441          const std::string sType ( "_" + 
01442                                    std::string( 10>cryType ? "0" : "") + 
01443                                    int_to_string( cryType ) ) ;
01444 
01445          LogDebug("EcalGeom") << "Crytype=" << cryType ;
01446          const double ANom ( vecNomCryDimAR()[ cryType-1 ] ) ;
01447          const double BNom ( vecNomCryDimCR()[ cryType-1 ] ) ;
01448          const double bNom ( vecNomCryDimCF()[ cryType-1 ] ) ;
01449          const double HNom ( vecNomCryDimBR()[ cryType-1 ] ) ;
01450          const double hNom ( vecNomCryDimBF()[ cryType-1 ] ) ;
01451 
01452          const double alfCry ( 90*deg + atan( ( bNom - bUnd - aNom + aUnd )/
01453                                               ( hNom - hUnd ) ) ) ;
01454 
01455          const Trap trapCry (
01456             ( ANom - AUnd )/2.,           //double aHalfLengthXNegZLoY , // bl1, A/2
01457             ( aNom - aUnd )/2.,           //double aHalfLengthXPosZLoY , // bl2, a/2
01458             ( bNom - bUnd )/2.,           //double aHalfLengthXPosZHiY , // tl2, b/2
01459             ( HNom - HUnd )/2.,           //double aHalfLengthYNegZ    , // h1, H/2
01460             ( hNom - hUnd )/2.,           //double aHalfLengthYPosZ    , // h2, h/2
01461             ( LNom - LUnd )/2.,           //double aHalfLengthZ        , // dz,  L/2
01462             alfCry,                       //double aAngleAD            , // alfa1
01463             aNom - aUnd - ANom + AUnd,    //double aCoord15X           , // x15
01464             hNom - hUnd - HNom + HUnd     //double aCoord15Y             // y15      
01465          ) ;
01466 
01467          const DDName        cryDDName ( cryName() + sType ) ;
01468          const DDSolid       crySolid  ( mytrap( cryDDName.name(), trapCry ) ) ;
01469          const DDLogicalPart cryLog    ( cryDDName, cryMat(), crySolid ) ;
01470 
01471 
01472 //++++++++++++++++++++++++++++++++++  APD ++++++++++++++++++++++++++++++++++
01473          const unsigned int copyCap ( 1 ) ;
01474 
01475          const DDName        capDDName ( capName().name() + sType ) ;
01476 
01477          DDSolid capSolid ( DDSolidFactory::box( capDDName, 
01478                                                  capXSize()/2.,
01479                                                  capYSize()/2.,  
01480                                                  capThick()/2.   ) ) ;
01481          
01482          const DDLogicalPart capLog ( capDDName, capMat(), capSolid ) ;
01483 
01484          const DDName        sglDDName ( sglName().name() + sType ) ;
01485 
01486          DDSolid sglSolid ( DDSolidFactory::box( sglDDName, 
01487                                                  capXSize()/2.,
01488                                                  capYSize()/2.,  
01489                                                  sglThick()/2.   ) ) ;
01490 
01491          const DDLogicalPart sglLog ( sglDDName, sglMat(), sglSolid ) ;
01492          
01493          const unsigned int copySGL ( 1 ) ;
01494 
01495          const DDName        cerDDName ( cerName().name() + sType ) ;
01496 
01497          DDSolid cerSolid ( DDSolidFactory::box( cerDDName, 
01498                                                  cerXSize()/2.,
01499                                                  cerYSize()/2.,  
01500                                                  cerThick()/2.   ) ) ;
01501 
01502          const DDLogicalPart cerLog ( cerDDName, cerMat(), cerSolid ) ;
01503          
01504          unsigned int copyCER ( 0 ) ;
01505 
01506             
01507          const DDName        bsiDDName ( bsiName().name() + sType ) ;
01508 
01509          DDSolid bsiSolid ( DDSolidFactory::box( bsiDDName, 
01510                                                  bsiXSize()/2.,
01511                                                  bsiYSize()/2.,  
01512                                                  bsiThick()/2.   ) ) ;
01513 
01514          const DDLogicalPart bsiLog ( bsiDDName, bsiMat(), bsiSolid ) ;
01515          
01516          const unsigned int copyBSi ( 1 ) ;
01517 
01518          const DDName        atjDDName ( atjName().name() + sType ) ;
01519 
01520          DDSolid atjSolid ( DDSolidFactory::box( atjDDName, 
01521                                                  apdSide()/2.,
01522                                                  apdSide()/2.,  
01523                                                  atjThick()/2.   ) ) ;
01524 
01525          const DDLogicalPart atjLog ( atjDDName, atjMat(), atjSolid ) ;
01526          
01527          const unsigned int copyATJ ( 1 ) ;
01528 
01529 
01530          const DDName        aglDDName ( aglName().name() + sType ) ;
01531 
01532          DDSolid aglSolid ( DDSolidFactory::box( aglDDName, 
01533                                                  bsiXSize()/2.,
01534                                                  bsiYSize()/2.,  
01535                                                  aglThick()/2.   ) ) ;
01536 
01537          const DDLogicalPart aglLog ( aglDDName, aglMat(), aglSolid ) ;
01538          
01539          const unsigned int copyAGL ( 1 ) ;
01540 
01541 
01542          const DDName        andDDName ( andName().name() + sType ) ;
01543 
01544          DDSolid andSolid ( DDSolidFactory::box( andDDName, 
01545                                                  apdSide()/2.,
01546                                                  apdSide()/2.,  
01547                                                  andThick()/2.   ) ) ;
01548 
01549          const DDLogicalPart andLog ( andDDName, andMat(), andSolid ) ;
01550          
01551          const unsigned int copyAND ( 1 ) ;
01552 
01553 
01554          const DDName        apdDDName ( apdName().name() + sType ) ;
01555 
01556          DDSolid apdSolid ( DDSolidFactory::box( apdDDName, 
01557                                                  apdSide()/2.,
01558                                                  apdSide()/2.,  
01559                                                  apdThick()/2.   ) ) ;
01560 
01561          const DDLogicalPart apdLog ( apdDDName, apdMat(), apdSolid ) ;
01562          
01563          const unsigned int copyAPD ( 1 ) ;
01564 //++++++++++++++++++++++++++++++++++ END APD ++++++++++++++++++++++++++++++++++
01565 
01566 
01567          const double delta     ( atan( ( HNom - hNom )/LNom ) ) ;
01568 //unused         const double cosdelta  ( cos( delta ) ) ;
01569          const double sindelta  ( sin( delta ) ) ;
01570 
01571          const double gamma     ( atan( ( ANom - aNom )/LNom ) ) ;
01572 //unused         const double cosgamma  ( cos( gamma ) ) ;
01573          const double singamma  ( sin( gamma ) ) ;
01574 
01575          const double beta      ( atan( ( BNom - bNom )/LNom ) ) ;
01576 //unused         const double cosbeta   ( cos( beta ) ) ;
01577          const double sinbeta   ( sin( beta ) ) ;
01578 
01579          // Now clearance trap
01580          const double alfClr ( 90*deg + atan( ( bNom - aNom )/( hNom + sClr ) ) ) ;
01581 
01582          const Trap trapClr (
01583             ( ANom + sClr + rClr*singamma )/2.,    //double aHalfLengthXNegZLoY , // bl1, A/2
01584             ( aNom + sClr - fClr*singamma )/2.,    //double aHalfLengthXPosZLoY , // bl2, a/2
01585             ( bNom + sClr - fClr*sinbeta  )/2.,    //double aHalfLengthXPosZHiY , // tl2, b/2
01586             ( HNom + sClr + rClr*sindelta )/2.,    //double aHalfLengthYNegZ    , // h1,  H/2
01587             ( hNom + sClr - fClr*sindelta )/2.,    //double aHalfLengthYPosZ    , // h2,  h/2
01588             ( LNom + fClr + rClr )/2., // dz,  L/2
01589             alfClr,                //double aAngleAD            , // alfa1
01590             aNom - ANom ,          //double aCoord15X           , // x15
01591             hNom - HNom            //double aCoord15Y             // y15  
01592          ) ;
01593 
01594          const DDName        clrDDName ( clrName() + sType ) ;
01595          const DDSolid       clrSolid  ( mytrap( clrDDName.name(), trapClr ) ) ;
01596          const DDLogicalPart clrLog    ( clrDDName, clrMat(), clrSolid ) ;
01597 
01598          // Now wrap trap
01599 
01600          const double alfWrap ( 90*deg + atan( ( bNom - aNom )/
01601                                                ( hNom + sClr + 2*sWrap ) ) ) ;
01602 
01603          const Trap trapWrap (
01604             ( trapClr.A() + 2*sWrap + rWrap*singamma )/2, // bl1, A/2
01605             ( trapClr.a() + 2*sWrap - fWrap*singamma )/2, // bl2, a/2
01606             ( trapClr.b() + 2*sWrap - fWrap*sinbeta  )/2, // tl2, b/2
01607             ( trapClr.H() + 2*sWrap + rWrap*sindelta )/2, // h1,  H/2
01608             ( trapClr.h() + 2*sWrap - fWrap*sindelta )/2, // h2,  h/2
01609             ( trapClr.L() + fWrap + rWrap )/2., // dz,  L/2
01610             alfWrap,                       //double aAngleAD            , // alfa1
01611             aNom - ANom - (cryType>9 ? 0 : 0.020*mm) ,
01612             hNom - HNom                    //double aCoord15Y             // y15  
01613          ) ;
01614 
01615          const DDName        wrapDDName ( wrapName() + sType ) ;
01616          const DDSolid       wrapSolid  ( mytrap( wrapDDName.name(), trapWrap ) ) ;
01617          const DDLogicalPart wrapLog    ( wrapDDName, wrapMat(), wrapSolid ) ;
01618 
01619          // Now wall trap
01620 
01621          const double alfWall ( 90*deg + atan( ( bNom - aNom )/
01622                                                ( hNom + sClr + 2*sWrap + 2*sWall ) ) ) ;
01623 
01624          const Trap trapWall (
01625             ( trapWrap.A() + 2*sWall + rWall*singamma )/2,  // A/2 
01626             ( trapWrap.a() + 2*sWall - fWall*singamma )/2,  // a/2
01627             ( trapWrap.b() + 2*sWall - fWall*sinbeta  )/2,  // b/2
01628             ( trapWrap.H() + 2*sWall + rWall*sindelta )/2,  // H/2
01629             ( trapWrap.h() + 2*sWall - fWall*sindelta )/2,  // h/2
01630             ( trapWrap.L() + fWall + rWall )/2.,  // L/2
01631             alfWall,                             // alfa1
01632             aNom - ANom - (cryType<10? 0.150*mm : 0.100*mm ) ,       
01633             hNom - HNom                          // y15
01634          ) ;
01635 
01636          const DDName        wallDDName ( wallName() + sType ) ;
01637          const DDSolid       wallSolid  ( mytrap( wallDDName.name(), trapWall ) ) ;
01638          const DDLogicalPart wallLog    ( wallDDName, wallMat(), wallSolid ) ;
01639          
01640 /*       std::cout << "Traps:\n a: " 
01641                 << trapCry.a() << ", " 
01642                 << trapClr.a() << ", " 
01643                 << trapWrap.a() << ", " 
01644                 << trapWall.a() << "\n b: " 
01645                 << trapCry.b() << ", " 
01646                 << trapClr.b() << ", " 
01647                 << trapWrap.b() << ", " 
01648                 << trapWall.b() << "\n A: " 
01649                 << trapCry.A() << ", " 
01650                 << trapClr.A() << ", " 
01651                 << trapWrap.A() << ", " 
01652                 << trapWall.A() << "\n B: " 
01653                 << trapCry.B() << ", " 
01654                 << trapClr.B() << ", " 
01655                 << trapWrap.B() << ", " 
01656                 << trapWall.B() << "\n h: " 
01657                 << trapCry.h() << ", " 
01658                 << trapClr.h() << ", " 
01659                 << trapWrap.h() << ", " 
01660                 << trapWall.h() << "\n H: " 
01661                 << trapCry.H() << ", " 
01662                 << trapClr.H() << ", " 
01663                 << trapWrap.H() << ", " 
01664                 << trapWall.H() << "\n a1: " 
01665                 << trapCry.a1()/deg << ", " 
01666                 << trapClr.a1()/deg << ", " 
01667                 << trapWrap.a1()/deg << ", " 
01668                 << trapWall.a1()/deg << "\n a4: " 
01669                 << trapCry.a4()/deg << ", " 
01670                 << trapClr.a4()/deg << ", " 
01671                 << trapWrap.a4()/deg << ", " 
01672                 << trapWall.a4()/deg << "\n x15: " 
01673                 << trapCry.x15() << ", " 
01674                 << trapClr.x15() << ", " 
01675                 << trapWrap.x15() << ", " 
01676                 << trapWall.x15() << "\n y15: " 
01677                 << trapCry.y15() << ", " 
01678                 << trapClr.y15() << ", " 
01679                 << trapWrap.y15() << ", " 
01680                 << trapWall.y15()
01681                 << std::endl ;
01682 */
01683          // Now for placement of cry within clr
01684          const Vec3 cryToClr ( 0, 0, ( rClr - fClr )/2 ) ;
01685 
01686          cpv.position( cryLog,
01687                 clrLog, 
01688                 copyOne, 
01689                 DDTranslation ( 0, 0, ( rClr - fClr )/2 ), //SAME as cryToClr above.
01690                 DDRotation() ) ;
01691 
01692          if( 0 != capHere() )
01693          { 
01694             cpv.position( aglLog,
01695                           bsiLog, 
01696                           copyAGL, 
01697                           DDTranslation( 0,
01698                                          0,
01699                                          - aglThick()/2. + bsiThick()/2. ),
01700                           DDRotation() ) ;
01701 
01702             cpv.position( andLog,
01703                           bsiLog, 
01704                           copyAND, 
01705                           DDTranslation( 0,
01706                                          0,
01707                                          - andThick()/2. - aglThick() + bsiThick()/2. ),
01708                           DDRotation() ) ;
01709 
01710             cpv.position( apdLog,
01711                           bsiLog, 
01712                           copyAPD, 
01713                           DDTranslation( 0,
01714                                          0,
01715                                          - apdThick()/2. - andThick()
01716                                          - aglThick() + bsiThick()/2. ),
01717                           DDRotation() ) ;
01718 
01719             cpv.position( atjLog,
01720                           bsiLog, 
01721                           copyATJ, 
01722                           DDTranslation( 0,
01723                                          0,
01724                                          - atjThick()/2. - apdThick() - andThick()
01725                                          - aglThick() + bsiThick()/2. ),
01726                           DDRotation() ) ;
01727 
01728             cpv.position( bsiLog,
01729                           cerLog, 
01730                           copyBSi, 
01731                           DDTranslation( 0,
01732                                          0,
01733                                          - bsiThick()/2. + cerThick()/2. ),
01734                           DDRotation() ) ;
01735 
01736             cpv.position( sglLog,
01737                           capLog, 
01738                           copySGL, 
01739                           DDTranslation( 0,
01740                                          0,
01741                                          - sglThick()/2. + capThick()/2. ),
01742                           DDRotation() ) ;
01743 
01744             for( unsigned int ijkl ( 0 ) ; ijkl != 2 ; ++ijkl )
01745             {
01746                cpv.position( cerLog,
01747                              capLog, 
01748                              ++copyCER, 
01749                              DDTranslation( trapCry.bl1() - ( 0 == ijkl ? apdX1() : apdX2() ),
01750                                             trapCry.h1()  - apdZ(),
01751                                             - sglThick() - cerThick()/2. + capThick()/2. ),
01752                              DDRotation() ) ;
01753             }
01754 
01755             cpv.position( capLog,
01756                           clrLog, 
01757                           copyCap, 
01758                           DDTranslation( 0 ,
01759                                          0 ,
01760                                          - trapCry.dz()  - capThick()/2. + (rClr - fClr)/2. ),
01761                           DDRotation() ) ;
01762          }
01763 
01764 
01765          const Vec3 clrToWrap ( 0, 0, ( rWrap - fWrap )/2 ) ;
01766 
01767          cpv.position( clrLog,
01768                 wrapLog, 
01769                 copyOne, 
01770                 DDTranslation ( 0, 0, ( rWrap - fWrap )/2 ), //SAME as cryToWrap
01771                 DDRotation() ) ;
01772 
01773 
01774          // Now for placement of clr within wall
01775          const Vec3 wrapToWall1 ( 0, 0, ( rWall - fWall )/2 ) ;
01776          const Vec3 wrapToWall ( Vec3( (cryType>9?0:0.005*mm),0,0 )+wrapToWall1 ) ;
01777 
01778          cpv.position( wrapLog,
01779                 wallLog, 
01780                 copyOne, 
01781                 DDTranslation ( Vec3( (cryType>9?0:0.005*mm),0,0 )+wrapToWall1 ), //SAME as wrapToWall
01782                 DDRotation() ) ;
01783 
01784          const Trap::VertexList vWall ( trapWall.vertexList() ) ;
01785          const Trap::VertexList vCry  ( trapCry.vertexList() ) ;
01786 
01787          const double sidePrime  ( ( trapWall.a() - trapCry.a() )/2 ) ;
01788          const double frontPrime ( fWall + fWrap + fClr + LUnd/2 ) ;
01789 
01790          // define web plates with clearance ===========================================
01791 
01792          if( 1 == cryType ) // first web plate: inside clearance volume
01793          {
01794             web( 0,
01795                  trapWall.b(),
01796                  trapWall.B(),
01797                  trapWall.L(),
01798                  theta,
01799                  vHAW[4] + Pt3D( 0, hawYOffCry(), 0 ),
01800                  hawRLog,
01801                  zee,
01802                  sidePrime,
01803                  frontPrime,
01804                  delta, cpv ) ;
01805             zee += vecGapAlvEta()[0] ;
01806          }
01807 
01808          for( unsigned int etaAlv ( 1 ) ; etaAlv <= nCryPerAlvEta() ; ++etaAlv )
01809          {
01810             LogDebug("EcalGeom") << "theta=" << theta/deg
01811                       << ", sidePrime=" << sidePrime << ", frontPrime=" << frontPrime
01812                       << ",  zeta="<<zeta<<", delta="<<delta<<",  zee=" << zee;
01813 
01814             zee += 0.075*mm +
01815                ( side*cos(zeta) + trapWall.h() - sidePrime )/sin(theta) ;
01816 
01817             LogDebug("EcalGeom") << "New zee="<< zee ;
01818 
01819             // make transform for placing enclosed crystal
01820 
01821             const Pt3D trap2 ( vCry[2] + cryToClr + clrToWrap + wrapToWall ) ;
01822             
01823             const Pt3D trap3 ( trap2 + Pt3D( 0,           
01824                                              -trapCry.h(),
01825                                              0 ) ) ;
01826             const Pt3D trap1 ( trap3 + Pt3D( -trapCry.a(),
01827                                              0,           
01828                                              0 ) ) ;
01829 
01830             const Pt3D wedge3 ( vHAW[4] + Pt3D( sidePrime,
01831                                                 hawYOffCry(), 
01832                                                 zee ) ) ;
01833             const Pt3D wedge2 ( wedge3  + Pt3D( 0,
01834                                                 trapCry.h()*cos(theta),
01835                                                 -trapCry.h()*sin(theta)  ) ) ;
01836             const Pt3D wedge1 ( wedge3  + Pt3D( trapCry.a(),
01837                                                 0,
01838                                                 0            ) ) ;
01839 
01840             const Tf3D tForm1 ( trap1,  trap2,  trap3,
01841                                 wedge1, wedge2, wedge3    ) ;
01842 
01843             const double xx ( 0.050*mm ) ;
01844 
01845             const Tf3D tForm ( HepGeom::Translate3D(xx,0,0)*tForm1 ) ;
01846 
01847             cpv.position( wallLog,
01848                    hawRLog, 
01849                    etaAlv, 
01850                    DDTranslation(tForm.getTranslation().x(), tForm.getTranslation().y(), tForm.getTranslation().z() ),
01851                    myrot( wallLog.name().name() + "_" + int_to_string( etaAlv ),
01852                           tForm.getRotation() ) ) ;
01853 
01854             theta     -= delta ;
01855             side       = sidePrime ;
01856             zeta       = delta ;
01857          }
01858          if( 5 == cryType ||
01859              9 == cryType ||
01860             13 == cryType ||
01861             17 == cryType    ) // web plates
01862          {
01863             const unsigned int webIndex ( cryType/4 ) ;
01864             zee += 0.5*vecGapAlvEta()[cryType]/sin(theta) ;
01865             web( webIndex,
01866                  trapWall.a(),
01867                  trapWall.A(),
01868                  trapWall.L(),
01869                  theta,
01870                  vHAW[4] + Pt3D( 0, hawYOffCry(), 0 ),
01871                  hawRLog,
01872                  zee ,
01873                  sidePrime,
01874                  frontPrime,
01875                  delta, cpv ) ;
01876             zee += 0.5*vecGapAlvEta()[cryType]/sin(theta) ;
01877          }
01878          else
01879          {
01880             if( 17 != cryType ) zee += vecGapAlvEta()[cryType]/sin(theta) ;
01881          }
01882       }
01883       // END   filling Wedge with crystal plus supports --------------------------
01884 
01885 //------------------------------------------------------------------------
01886 //------------------------------------------------------------------------
01887 //------------------------------------------------------------------------
01888 //------------------------------------------------------------------------
01889 //**************** Material at outer radius of supermodule ***************
01890 //------------------------------------------------------------------------
01891 //------------------------------------------------------------------------
01892 //------------------------------------------------------------------------
01893 //------------------------------------------------------------------------
01894 
01895       if( 0 != backHere() )
01896       {
01897 
01903       
01904       const DDTranslation outtra ( backXOff() + backSideHeight()/2,
01905                                    backYOff(),
01906                                    backSideLength()/2 ) ;
01907 
01908       const double realBPthick ( backPlateThick() + backPlate2Thick() ) ;
01909 
01910       DDSolid backPlateSolid ( DDSolidFactory::box( backPlateName(), 
01911                                                     backPlateWidth()/2.,  
01912                                                     realBPthick/2.,
01913                                                     backPlateLength()/2.   ) ) ;
01914       const std::vector<double>& backPlateParms ( backPlateSolid.parameters() ) ;
01915       const DDLogicalPart backPlateLog ( backPlateName(),
01916                                          backPlateMat(),
01917                                          backPlateSolid ) ;
01918       
01919       const DDTranslation backPlateTra ( backSideHeight()/2 + 
01920                                          backPlateParms[1],
01921                                          0*mm,
01922                                          backPlateParms[2] -
01923                                          backSideLength()/2 ) ;
01924 
01925       DDSolid backPlate2Solid ( DDSolidFactory::box( backPlate2Name(), 
01926                                                     backPlateWidth()/2.,  
01927                                                     backPlate2Thick()/2.,
01928                                                     backPlateLength()/2.   ) ) ;
01929 
01930       const DDLogicalPart backPlate2Log ( backPlate2Name(),
01931                                           backPlate2Mat(),
01932                                           backPlate2Solid ) ;
01933       
01934       const DDTranslation backPlate2Tra ( 0,
01935                                           -backPlateParms[1] + backPlate2Thick()/2., 0 ) ;
01936       if( 0 != backPlateHere() )
01937       {
01938          cpv.position( backPlate2Log,
01939                 backPlateName(), 
01940                 copyOne, 
01941                 backPlate2Tra,
01942                 DDRotation() ) ;
01943 
01944          cpv.position( backPlateLog,
01945                 spmName(), 
01946                 copyOne, 
01947                 outtra + backPlateTra,
01948                 myrot( backPlateName().name()+"Rot5",
01949                        CLHEP::HepRotationZ(270*deg)    ) ) ;
01950 
01951       }
01957 
01958 
01964 
01965       const Trap trapBS (
01966          backSideWidth()/2.,  //double aHalfLengthXNegZLoY , // bl1, A/2
01967          backSideWidth()/2.,  //double aHalfLengthXPosZLoY , // bl2, a/2
01968          backSideWidth()/4.,  //double aHalfLengthXPosZHiY , // tl2, b/2
01969          backSideHeight()/2., //double aHalfLengthYNegZ    , // h1, H/2
01970          backSideHeight()/2., //double aHalfLengthYPosZ    , // h2, h/2
01971          backSideLength()/2., //double aHalfLengthZ        , // dz,  L/2
01972          backSideAngle(),              //double aAngleAD            , // alfa1
01973          0,                   //double aCoord15X           , // x15
01974          0                    //double aCoord15Y             // y15
01975          ) ;
01976 
01977       const DDSolid       backSideSolid ( mytrap( backSideName().name(), trapBS ) ) ;
01978       const DDLogicalPart backSideLog ( backSideName(), 
01979                                         backSideMat(), 
01980                                         backSideSolid ) ;
01981       
01982       const DDTranslation backSideTra1 ( 0*mm,
01983                                          backPlateWidth()/2 + backSideYOff1(),
01984                                          1*mm ) ;
01985       if( 0 != backSideHere() )
01986       {
01987          cpv.position( backSideLog,
01988                 spmName(), 
01989                 copyOne, 
01990                 outtra + backSideTra1,
01991                 myrot( backSideName().name()+"Rot8",
01992                        CLHEP::HepRotationX(180*deg)*CLHEP::HepRotationZ(90*deg)    ) ) ;
01993              
01994          const DDTranslation backSideTra2( 0*mm,
01995                                            -backPlateWidth()/2 + backSideYOff2(),
01996                                            1*mm ) ;
01997          cpv.position( backSideLog,
01998                 spmName(), 
01999                 copyTwo, 
02000                 outtra + backSideTra2,
02001                 myrot( backSideName().name()+"Rot9",
02002                        CLHEP::HepRotationZ(90*deg)    ) ) ;
02003       }
02009              
02010 //=====================
02011       const double backCoolWidth ( backCoolBarWidth() + 2.*backCoolTankWidth() ) ;
02012 
02018 
02019       const double manifCut ( 2*mm ) ;
02020 
02021       DDSolid mBManifSolid ( DDSolidFactory::tubs( mBManifName() ,
02022                                                    backCoolWidth/2. - manifCut,
02023                                                    0, 
02024                                                    mBManifOutDiam()/2,
02025                                                    0*deg, 360*deg ) ) ;
02026       const DDLogicalPart mBManifLog ( mBManifName(), mBManifMat(), mBManifSolid ) ;
02027 
02028       const DDName mBManifWaName ( ddname( mBManifName().name() + "Wa" ) ) ;
02029       DDSolid mBManifWaSolid ( DDSolidFactory::tubs( mBManifWaName ,
02030                                                      backCoolWidth/2.-manifCut,
02031                                                      0, 
02032                                                      mBManifInnDiam()/2,
02033                                                      0*deg, 360*deg ) ) ;
02034       const DDLogicalPart mBManifWaLog ( mBManifWaName, backPipeWaterMat(), 
02035                                          mBManifWaSolid ) ;
02036       cpv.position( mBManifWaLog,
02037              mBManifName(), 
02038              copyOne, 
02039              DDTranslation(0,0,0),
02040              DDRotation() ) ;
02041 
02047 //=====================
02048 
02049 
02050 
02056       const double deltaY ( -5*mm ) ;
02057 
02058       DDSolid grEdgeSlotSolid ( DDSolidFactory::box( grEdgeSlotName(), 
02059                                                      grEdgeSlotHeight()/2.,  
02060                                                      grEdgeSlotWidth()/2.,
02061                                                      grilleThick()/2.   ) ) ;
02062       const DDLogicalPart grEdgeSlotLog ( grEdgeSlotName(), grEdgeSlotMat(), grEdgeSlotSolid );
02063 
02064       unsigned int edgeSlotCopy ( 0 ) ;
02065       unsigned int midSlotCopy ( 0 ) ;
02066 
02067       DDLogicalPart grMidSlotLog[4] ;
02068 
02069       for( unsigned int iGr ( 0 ) ; iGr != vecGrilleHeight().size() ; ++iGr )
02070       {
02071          DDName gName ( ddname( grilleName() + int_to_string( iGr ) ) ) ;
02072          DDSolid grilleSolid ( DDSolidFactory::box( gName, 
02073                                                     vecGrilleHeight()[iGr]/2.,  
02074                                                     backCoolWidth/2.,
02075                                                     grilleThick()/2.   ) ) ;
02076          const DDLogicalPart grilleLog ( gName,
02077                                          grilleMat(),
02078                                          grilleSolid ) ;
02079          
02080          const DDTranslation grilleTra ( -realBPthick/2 -
02081                                          vecGrilleHeight()[iGr]/2,
02082                                          deltaY,
02083                                          vecGrilleZOff()[iGr] +
02084                                          grilleThick()/2 - backSideLength()/2 ) ;
02085          const DDTranslation gTra ( outtra + backPlateTra + grilleTra ) ;
02086 
02087          if( 0 != grMidSlotHere() &&
02088              0 != iGr   )
02089          {
02090             if( 0 == (iGr-1)%2      )
02091             {
02092                DDName mName ( ddname( grMidSlotName() + int_to_string( iGr/2 ) ) ) ;
02093                DDSolid grMidSlotSolid ( DDSolidFactory::box(
02094                                            mName, 
02095                                            vecGrMidSlotHeight()[(iGr-1)/2]/2.,
02096                                            grMidSlotWidth()/2.,
02097                                            grilleThick()/2.   ) ) ;
02098                grMidSlotLog[(iGr-1)/2] = DDLogicalPart( mName, grMidSlotMat(), grMidSlotSolid ) ;
02099             }          
02100             cpv.position( grMidSlotLog[(iGr-1)/2],
02101                    gName, 
02102                    ++midSlotCopy, 
02103                    DDTranslation( vecGrilleHeight()[iGr]/2. - vecGrMidSlotHeight()[(iGr-1)/2]/2.,
02104                                   +grMidSlotXOff(),    0 ),
02105                    DDRotation() ) ;
02106             cpv.position( grMidSlotLog[(iGr-1)/2],
02107                    gName, 
02108                    ++midSlotCopy, 
02109                    DDTranslation( vecGrilleHeight()[iGr]/2. - vecGrMidSlotHeight()[(iGr-1)/2]/2.,
02110                          -grMidSlotXOff(),    0 ),
02111                    DDRotation() ) ;
02112          }
02113 
02114          if( 0 != grEdgeSlotHere() &&
02115              0 != iGr                   )
02116          {
02117             cpv.position( grEdgeSlotLog,
02118                    gName, 
02119                    ++edgeSlotCopy, 
02120                    DDTranslation( vecGrilleHeight()[iGr]/2. - grEdgeSlotHeight()/2.,
02121                                   backCoolWidth/2           - grEdgeSlotWidth()/2.,    0 ),
02122                    DDRotation() ) ;
02123             cpv.position( grEdgeSlotLog,
02124                    gName, 
02125                    ++edgeSlotCopy, 
02126                    DDTranslation( vecGrilleHeight()[iGr]/2. - grEdgeSlotHeight()/2.,
02127                          -backCoolWidth/2          + grEdgeSlotWidth()/2.,    0 ),
02128                    DDRotation() ) ;
02129          }
02130          if( 0 != grilleHere() )
02131             cpv.position( grilleLog,
02132                    spmName(), 
02133                    iGr, 
02134                    gTra,
02135                    DDRotation() ) ;
02136 
02137          if( ( 0 != iGr%2 )         &&
02138              ( 0 != mBManifHere() )     )
02139          {
02140             cpv.position( mBManifLog,
02141                    spmName(),
02142                    iGr,
02143                    gTra - DDTranslation( -mBManifOutDiam()/2. +
02144                                          vecGrilleHeight()[iGr]/2.,manifCut, 
02145                                          grilleThick()/2.+3*mBManifOutDiam()/2.) ,
02146                    myrot( mBManifName().name()+"R1",
02147                           CLHEP::HepRotationX(90*deg)             ) ) ;
02148             cpv.position( mBManifLog,
02149                    spmName(),
02150                    iGr-1,
02151                    gTra - DDTranslation( -3*mBManifOutDiam()/2. +
02152                                          vecGrilleHeight()[iGr]/2.,manifCut, 
02153                                          grilleThick()/2+3*mBManifOutDiam()/2.) ,
02154                    myrot( mBManifName().name()+"R2",
02155                           CLHEP::HepRotationX(90*deg)             ) ) ;
02156          }
02157       }
02158 
02164 
02165 
02171 
02172       DDSolid backCoolBarSolid ( DDSolidFactory::box( backCoolBarName(), 
02173                                                       backCoolBarHeight()/2.,
02174                                                       backCoolBarWidth()/2.,  
02175                                                       backCoolBarThick()/2.   ) ) ;
02176       const DDLogicalPart backCoolBarLog ( backCoolBarName(),
02177                                            backCoolBarMat(),
02178                                            backCoolBarSolid ) ;
02179 
02180       DDSolid backCoolBarSSSolid ( DDSolidFactory::box( backCoolBarSSName(), 
02181                                                         backCoolBarHeight()/2.,
02182                                                         backCoolBarWidth()/2.,  
02183                                                         backCoolBarSSThick()/2.   ) ) ;
02184       const DDLogicalPart backCoolBarSSLog ( backCoolBarSSName(),
02185                                              backCoolBarSSMat(),
02186                                              backCoolBarSSSolid ) ;
02187       const DDTranslation backCoolBarSSTra (0,0,0) ;
02188       cpv.position( backCoolBarSSLog,
02189              backCoolBarName(), 
02190              copyOne, 
02191              backCoolBarSSTra,
02192              DDRotation() ) ;
02193 
02194       DDSolid backCoolBarWaSolid ( DDSolidFactory::box( backCoolBarWaName(), 
02195                                                         backCoolBarHeight()/2.,
02196                                                         backCoolBarWidth()/2.,  
02197                                                         backCoolBarWaThick()/2.   ) ) ;
02198       const DDLogicalPart backCoolBarWaLog ( backCoolBarWaName(),
02199                                              backCoolBarWaMat(),
02200                                              backCoolBarWaSolid ) ;
02201       const DDTranslation backCoolBarWaTra (0,0,0) ;
02202       cpv.position( backCoolBarWaLog,
02203              backCoolBarSSName(), 
02204              copyOne, 
02205              backCoolBarWaTra,
02206              DDRotation() ) ;
02207 
02213 
02214 
02220 
02221       double thickVFE ( 0 ) ;
02222       for( unsigned int iLyr ( 0 ) ; iLyr != vecBackVFELyrThick().size() ; ++iLyr )
02223       {
02224          thickVFE += vecBackVFELyrThick()[iLyr] ;
02225       }
02226       DDSolid backVFESolid ( DDSolidFactory::box( backVFEName(), 
02227                                                   backCoolBarHeight()/2.,
02228                                                   backCoolBarWidth()/2.,  
02229                                                   thickVFE/2.   ) ) ;
02230       const DDLogicalPart backVFELog ( backVFEName(),
02231                                        backVFEMat(),
02232                                        backVFESolid ) ;
02233       DDTranslation offTra ( 0,0,-thickVFE/2 ) ;
02234       for( unsigned int iLyr ( 0 ) ; iLyr != vecBackVFELyrThick().size() ; ++iLyr )
02235       {
02236          DDSolid backVFELyrSolid ( DDSolidFactory::box( ddname(vecBackVFELyrName()[iLyr]), 
02237                                                         backCoolBarHeight()/2.,
02238                                                         backCoolBarWidth()/2.,  
02239                                                         vecBackVFELyrThick()[iLyr]/2.   ) ) ;
02240          const DDLogicalPart backVFELyrLog ( ddname(vecBackVFELyrName()[iLyr]),
02241                                              ddmat(vecBackVFELyrMat()[iLyr]),
02242                                              backVFELyrSolid ) ;
02243          const DDTranslation backVFELyrTra (0,0, vecBackVFELyrThick()[iLyr]/2) ;
02244          cpv.position( backVFELyrLog,
02245                 backVFEName(), 
02246                 copyOne, 
02247                 backVFELyrTra + offTra,
02248                 DDRotation() ) ;
02249          offTra += 2*backVFELyrTra ;
02250       }
02251 
02257 
02258 
02264 
02265       const double halfZCoolVFE ( thickVFE + backCoolBarThick()/2. ) ;
02266       DDSolid backCoolVFESolid ( DDSolidFactory::box( backCoolVFEName(), 
02267                                                       backCoolBarHeight()/2.,
02268                                                       backCoolBarWidth()/2.,  
02269                                                       halfZCoolVFE   ) ) ;
02270       const DDLogicalPart backCoolVFELog ( backCoolVFEName(),
02271                                            backCoolVFEMat(),
02272                                            backCoolVFESolid ) ;
02273       if( 0 != backCoolBarHere() )
02274          cpv.position( backCoolBarLog    ,
02275                 backCoolVFEName() , 
02276                 copyOne           , 
02277                 DDTranslation()   ,
02278                 DDRotation()       ) ;
02279       if( 0 != backCoolVFEHere() )
02280          cpv.position( backVFELog        ,
02281                 backCoolVFEName() , 
02282                 copyOne           , 
02283                 DDTranslation( 0,0, backCoolBarThick()/2. + thickVFE/2. )   ,
02284                 DDRotation()       ) ;
02285       cpv.position( backVFELog        ,
02286              backCoolVFEName() , 
02287              copyTwo           , 
02288              DDTranslation( 0,0, -backCoolBarThick()/2. - thickVFE/2. )   ,
02289              myrot( backVFEName().name() + "Flip",
02290                     CLHEP::HepRotationX( 180*deg ) )        ) ;
02291 
02297 
02298 
02304       unsigned int iCVFECopy ( 1 ) ;
02305       unsigned int iSep ( 0 ) ;
02306       unsigned int iNSec ( 0 ) ;
02307       const unsigned int nMisc ( vecBackMiscThick().size()/4 ) ;
02308       for( unsigned int iMod ( 0 ) ; iMod != 4 ; ++iMod )
02309       {
02310          const double pipeLength ( vecGrilleZOff()[2*iMod+1] -
02311                                    vecGrilleZOff()[2*iMod  ] -
02312                                    grilleThick()   - 3*mm            ) ;
02313 
02314          const double pipeZPos ( vecGrilleZOff()[2*iMod+1] - pipeLength/2 - 1.5*mm  ) ;
02315 
02316 
02317 
02318          // accumulate total height of parent volume
02319 
02320          double backCoolHeight ( backCoolBarHeight() + mBCoolTubeOutDiam() ) ;
02321          for( unsigned int iMisc ( 0 ) ; iMisc != nMisc ; ++iMisc )
02322          {
02323             backCoolHeight += vecBackMiscThick()[ iMod*nMisc + iMisc ] ;
02324          }
02325          double bottomThick ( mBCoolTubeOutDiam() ) ;
02326          for( unsigned int iMB ( 0 ) ; iMB != vecMBLyrThick().size() ; ++iMB )
02327          {
02328             backCoolHeight += vecMBLyrThick()[iMB] ;
02329             bottomThick    += vecMBLyrThick()[iMB] ;
02330          }
02331 
02332          DDName backCName ( ddname( vecBackCoolName()[iMod] ) ) ;
02333          const double halfZBCool ( ( pipeLength - 2*mBManifOutDiam() - grilleZSpace() )/2 ) ;
02334          DDSolid backCoolSolid ( DDSolidFactory::box( backCName ,
02335                                                       backCoolHeight/2.,  
02336                                                       backCoolWidth/2.,
02337                                                       halfZBCool   ) ) ;
02338          const DDLogicalPart backCoolLog ( backCName,
02339                                            spmMat(),
02340                                            backCoolSolid ) ;
02341          
02342          const DDTranslation bCoolTra ( -realBPthick/2 +
02343                                         backCoolHeight/2    -
02344                                         vecGrilleHeight()[2*iMod],
02345                                         deltaY,
02346                                         vecGrilleZOff()[2*iMod] +
02347                                         grilleThick() + grilleZSpace() +
02348                                         halfZBCool - 
02349                                         backSideLength()/2 ) ;
02350          if( 0 != backCoolHere() )
02351             cpv.position( backCoolLog,
02352                    spmName(), 
02353                    iMod+1, 
02354                    outtra + backPlateTra + bCoolTra,
02355                    DDRotation() ) ;
02356 
02357 //===
02358          const double backCoolTankHeight ( backCoolBarHeight() ) ;// - backBracketHeight() ) ;
02359 
02360          const double halfZTank ( halfZBCool - 5*cm ) ;
02361 
02362          DDName bTankName ( ddname( backCoolTankName()+int_to_string(iMod+1) ) ) ;
02363          DDSolid backCoolTankSolid ( DDSolidFactory::box( bTankName ,
02364                                                           backCoolTankHeight/2.,  
02365                                                           backCoolTankWidth()/2.,
02366                                                           halfZTank  ) ) ;
02367          const DDLogicalPart backCoolTankLog ( bTankName,
02368                                                backCoolTankMat(),
02369                                                backCoolTankSolid ) ;
02370          if( 0 != backCoolTankHere() )
02371             cpv.position( backCoolTankLog,
02372                    backCName, 
02373                    copyOne, 
02374                    DDTranslation( -backCoolHeight/2 + 
02375                                   backCoolTankHeight/2. + 
02376                                   bottomThick,
02377                                   backCoolBarWidth()/2. + backCoolTankWidth()/2., 0),
02378                    DDRotation() ) ;
02379 
02380          DDName bTankWaName ( ddname( backCoolTankWaName()+int_to_string(iMod+1) ) ) ;
02381          DDSolid backCoolTankWaSolid ( DDSolidFactory::box( bTankWaName ,
02382                                                             backCoolTankHeight/2. -
02383                                                             backCoolTankThick()/2.,  
02384                                                             backCoolTankWaWidth()/2.,
02385                                                             halfZTank -
02386                                                             backCoolTankThick()/2. ) ) ;
02387          const DDLogicalPart backCoolTankWaLog ( bTankWaName,
02388                                                  backCoolTankWaMat(),
02389                                                  backCoolTankWaSolid ) ;
02390          cpv.position( backCoolTankWaLog,
02391                 bTankName, 
02392                 copyOne, 
02393                 DDTranslation(0,0,0),
02394                 DDRotation() ) ;
02395 
02396          DDName bBracketName ( ddname( backBracketName()+int_to_string(iMod+1) ) ) ;
02397          DDSolid backBracketSolid ( DDSolidFactory::box( bBracketName ,
02398                                                          backBracketHeight()/2.,  
02399                                                          backCoolTankWidth()/2.,
02400                                                          halfZTank   ) ) ;
02401          const DDLogicalPart backBracketLog ( bBracketName,
02402                                               backBracketMat(),
02403                                               backBracketSolid ) ;
02404          if( 0 != backCoolTankHere() )
02405             cpv.position( backBracketLog,
02406                    backCName, 
02407                    copyOne, 
02408                    DDTranslation( backCoolBarHeight() - 
02409                                   backCoolHeight/2. - 
02410                                   backBracketHeight()/2. +
02411                                   bottomThick,
02412                                   -backCoolBarWidth()/2. - backCoolTankWidth()/2., 0),
02413                    DDRotation() ) ;
02414 
02415 /*       cpv.position( backBracketLog,
02416                 backCName, 
02417                 copyTwo, 
02418                 DDTranslation( backCoolBarHeight() - backCoolHeight/2. - backBracketHeight()/2.,
02419                                backCoolBarWidth()/2. + backCoolTankWidth()/2., 0),
02420                                DDRotation() ) ;*/
02421 
02422 //===
02423 
02424          DDTranslation bSumTra ( backCoolBarHeight() - 
02425                                  backCoolHeight/2. +
02426                                  bottomThick, 0, 0 ) ;
02427          for( unsigned int j ( 0 ) ; j != nMisc ; ++j ) // loop over miscellaneous layers
02428          {
02429             const DDName bName ( ddname( vecBackMiscName()[ iMod*nMisc + j ] ) ) ;
02430 
02431             DDSolid bSolid ( DDSolidFactory::box( bName ,
02432                                                   vecBackMiscThick()[ iMod*nMisc + j ]/2,  
02433                                                   backCoolBarWidth()/2. + backCoolTankWidth(),
02434                                                   halfZBCool ) ) ;
02435 
02436             const DDLogicalPart bLog ( bName, ddmat(vecBackMiscMat()[ iMod*nMisc + j ]), bSolid ) ;
02437  
02438             const DDTranslation bTra ( vecBackMiscThick()[ iMod*nMisc + j ]/2, 0*mm, 0*mm ) ;
02439 
02440 
02441             if( 0 != backMiscHere() )
02442                cpv.position( bLog,
02443                       backCName, 
02444                       copyOne, 
02445                       bSumTra + bTra,
02446                       DDRotation() ) ;
02447 
02448             bSumTra += 2*bTra ;
02449          }
02450 
02451          const double bHalfWidth ( backCoolBarWidth()/2. + backCoolTankWidth() ) ;
02452 
02453          if( 0 != mBLyrHere() )
02454          {
02455             DDTranslation mTra ( -backCoolHeight/2. + mBCoolTubeOutDiam(), 0, 0 ) ;
02456             for( unsigned int j ( 0 ) ; j != vecMBLyrThick().size() ; ++j ) // loop over MB layers
02457             {
02458                const DDName mName ( ddname( vecMBLyrName()[j] + "_" + 
02459                                             int_to_string(iMod+1) ) ) ;
02460 
02461                DDSolid mSolid ( DDSolidFactory::box( mName ,
02462                                                      vecMBLyrThick()[j]/2,  
02463                                                      bHalfWidth,
02464                                                      halfZBCool ) ) ;
02465 
02466                const DDLogicalPart mLog ( mName, ddmat(vecMBLyrMat()[j]), mSolid ) ;
02467  
02468                mTra += DDTranslation( vecMBLyrThick()[j]/2.0, 0*mm, 0*mm ) ;
02469                cpv.position( mLog,
02470                       backCName, 
02471                       copyOne, 
02472                       mTra,
02473                       DDRotation() ) ;
02474                mTra += DDTranslation( vecMBLyrThick()[j]/2.0, 0*mm, 0*mm ) ;
02475             }
02476          }
02477 
02478          if( 0 != mBCoolTubeHere() )
02479          {
02480             const DDName mBName ( ddname( mBCoolTubeName() + "_" + 
02481                                           int_to_string(iMod+1) ) ) ;
02482             
02483             DDSolid mBCoolTubeSolid ( DDSolidFactory::tubs( mBName ,
02484                                                             halfZBCool,
02485                                                             0, 
02486                                                             mBCoolTubeOutDiam()/2,
02487                                                             0*deg, 360*deg ) ) ;
02488             const DDLogicalPart mBLog ( mBName, mBCoolTubeMat(), mBCoolTubeSolid ) ;
02489 
02490             const DDName mBWaName ( ddname( mBCoolTubeName() + "Wa_" + 
02491                                             int_to_string(iMod+1) ) ) ;
02492             DDSolid mBCoolTubeWaSolid ( DDSolidFactory::tubs( mBWaName ,
02493                                                               halfZBCool,
02494                                                               0, 
02495                                                               mBCoolTubeInnDiam()/2,
02496                                                               0*deg, 360*deg ) ) ;
02497             const DDLogicalPart mBWaLog ( mBWaName, backPipeWaterMat(), 
02498                                           mBCoolTubeWaSolid ) ;
02499             cpv.position( mBWaLog,
02500                    mBName, 
02501                    copyOne, 
02502                    DDTranslation(0,0,0),
02503                    DDRotation() ) ;
02504 
02505             for( unsigned int j ( 0 ) ; j != mBCoolTubeNum() ; ++j ) // loop over all MB cooling circuits
02506             {
02507                cpv.position( mBLog,
02508                       backCName, 
02509                       2*j + 1, 
02510                       DDTranslation(-backCoolHeight/2.0+mBCoolTubeOutDiam()/2.,
02511                                     -bHalfWidth + (j+1)*bHalfWidth/5, 0),
02512                       DDRotation() ) ;
02513             }
02514          }
02515 
02516 
02522          if( 0 != backPipeHere() &&
02523              0 != iMod               )
02524          {
02525             DDName bPipeName ( ddname( backPipeName() + "_" + 
02526                                        int_to_string( iMod+1 ) ) ) ; 
02527             DDName bInnerName ( ddname( backPipeName() + 
02528                                         "_H2O_" + int_to_string( iMod+1 ) ) ) ; 
02529          
02530             DDSolid backPipeSolid ( DDSolidFactory::tubs( bPipeName ,
02531                                                           pipeLength/2,
02532                                                           0*mm, 
02533                                                           vecBackPipeDiam()[iMod]/2,
02534                                                           0*deg, 360*deg ) ) ;
02535 
02536             DDSolid backInnerSolid ( DDSolidFactory::tubs( bInnerName ,
02537                                                            pipeLength/2,
02538                                                            0*mm, 
02539                                                            vecBackPipeDiam()[iMod]/2 -
02540                                                            vecBackPipeThick()[iMod],
02541                                                            0*deg, 360*deg ) ) ;
02542 
02543             const DDLogicalPart backPipeLog ( bPipeName, 
02544                                               backPipeMat(), 
02545                                               backPipeSolid ) ;
02546 
02547             const DDLogicalPart backInnerLog ( bInnerName, 
02548                                                backPipeWaterMat(), 
02549                                                backInnerSolid ) ;
02550 
02551             const DDTranslation bPipeTra1 ( backXOff() + 
02552                                             backSideHeight() -
02553                                             0.7*vecBackPipeDiam()[iMod],
02554                                             backYOff() +
02555                                             backPlateWidth()/2 -
02556                                             backSideWidth() -
02557                                             0.7*vecBackPipeDiam()[iMod],
02558                                             pipeZPos ) ;
02559 
02560             cpv.position( backPipeLog,
02561                    spmName(), 
02562                    copyOne, 
02563                    bPipeTra1,
02564                    DDRotation() ) ;
02565 
02566             const DDTranslation bPipeTra2 ( bPipeTra1.x(),
02567                                             backYOff() -
02568                                             backPlateWidth()/2 +
02569                                             backSideWidth() +
02570                                             vecBackPipeDiam()[iMod],
02571                                             bPipeTra1.z()  ) ;
02572 
02573             cpv.position( backPipeLog,
02574                    spmName(), 
02575                    copyTwo, 
02576                    bPipeTra2,
02577                    DDRotation() ) ;
02578 
02579             cpv.position( backInnerLog,
02580                    bPipeName, 
02581                    copyOne, 
02582                    DDTranslation(),
02583                    DDRotation() ) ;
02584          }
02590 
02591 //=================================================
02592 
02593          if( 0 != dryAirTubeHere() )
02594          {
02595             DDName dryAirTubName ( ddname( dryAirTubeName() + int_to_string( iMod+1 ) ) ) ; 
02596 
02597             DDSolid dryAirTubeSolid ( DDSolidFactory::tubs( dryAirTubName ,
02598                                                             pipeLength/2,
02599                                                             dryAirTubeInnDiam()/2, 
02600                                                             dryAirTubeOutDiam()/2,
02601                                                             0*deg, 360*deg ) ) ;
02602 
02603             const DDLogicalPart dryAirTubeLog ( dryAirTubName , 
02604                                                 dryAirTubeMat(), 
02605                                                 dryAirTubeSolid ) ;
02606 
02607             const DDTranslation dryAirTubeTra1 ( backXOff() + 
02608                                                  backSideHeight() -
02609                                                  0.7*dryAirTubeOutDiam() -
02610                                                  vecBackPipeDiam()[iMod],
02611                                                  backYOff() +
02612                                                  backPlateWidth()/2 -
02613                                                  backSideWidth() -
02614                                                  1.2*dryAirTubeOutDiam(),
02615                                                  pipeZPos ) ;
02616 
02617             cpv.position( dryAirTubeLog,
02618                    spmName(), 
02619                    copyOne, 
02620                    dryAirTubeTra1,
02621                    DDRotation() ) ;
02622 
02623             const DDTranslation dryAirTubeTra2 ( dryAirTubeTra1.x(),
02624                                                  backYOff() -
02625                                                  backPlateWidth()/2 +
02626                                                  backSideWidth() +
02627                                                  0.7*dryAirTubeOutDiam() ,
02628                                                  dryAirTubeTra1.z()  ) ;
02629          
02630             cpv.position( dryAirTubeLog,
02631                    spmName(), 
02632                    copyTwo, 
02633                    dryAirTubeTra2,
02634                    DDRotation() ) ;
02635          }
02636          //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
02637 
02643 
02644          DDTranslation cTra ( backCoolBarHeight()/2. - 
02645                               backCoolHeight/2. +
02646                               bottomThick, 0 ,
02647                               -halfZTank + halfZCoolVFE ) ;
02648          const unsigned int numSec ( static_cast<unsigned int> (vecBackCoolNSec()[iMod]) ) ; 
02649          for( unsigned int jSec ( 0 ) ; jSec != numSec ; ++jSec )
02650          {
02651             const unsigned int nMax ( static_cast<unsigned int> (vecBackCoolNPerSec()[iNSec++]) ) ; 
02652             for( unsigned int iBar ( 0 ) ; iBar !=  nMax ; ++iBar )
02653             {
02654                cpv.position( backCoolVFELog,
02655                       backCName, 
02656                       iCVFECopy++, 
02657                       cTra,
02658                       DDRotation() ) ;         
02659                cTra += DDTranslation( 0, 0, backCBStdSep() ) ;
02660             }
02661             cTra -= DDTranslation( 0, 0, backCBStdSep() ) ; // backspace to previous
02662             if( jSec != numSec-1 ) cTra += DDTranslation( 
02663                0, 0, vecBackCoolSecSep()[iSep++] ) ; // now take atypical step
02664          }
02670       }
02671 
02677 
02683 
02684       double patchHeight ( 0  ) ;
02685       for( unsigned int iPatch ( 0 ) ; iPatch != vecPatchPanelThick().size() ; ++iPatch )
02686       {
02687          patchHeight += vecPatchPanelThick()[iPatch] ;
02688       }
02689 
02690       DDSolid patchSolid ( DDSolidFactory::box( patchPanelName() ,
02691                                                 patchHeight/2.,  
02692                                                 backCoolBarWidth()/2.,
02693                                                 ( vecSpmZPts().back() -
02694                                                   vecGrilleZOff().back() -
02695                                                   grilleThick() )/2   ) ) ;
02696 
02697       const std::vector<double>& patchParms ( patchSolid.parameters() ) ;
02698 
02699       const DDLogicalPart patchLog ( patchPanelName(), spmMat(), patchSolid ) ;
02700          
02701       const DDTranslation patchTra ( backXOff() + 4*mm ,
02702                                      0*mm,
02703                                      vecGrilleZOff().back() +
02704                                      grilleThick() +
02705                                      patchParms[2]  ) ;
02706       if( 0 != patchPanelHere() )
02707          cpv.position( patchLog,
02708                 spmName(), 
02709                 copyOne, 
02710                 patchTra,
02711                 DDRotation() ) ;
02712 
02713       DDTranslation pTra (-patchParms[0],0,0) ;
02714 
02715       for( unsigned int j ( 0 ) ; j != vecPatchPanelNames().size() ; ++j )
02716       {
02717          const DDName pName ( ddname( vecPatchPanelNames()[j] ) ) ;
02718 
02719          DDSolid pSolid ( DDSolidFactory::box( pName ,
02720                                                vecPatchPanelThick()[j]/2.,  
02721                                                patchParms[1],
02722                                                patchParms[2] ) ) ;
02723          
02724          const DDLogicalPart pLog ( pName, ddmat(vecPatchPanelMat()[j]), pSolid ) ;
02725          
02726          pTra += DDTranslation( vecPatchPanelThick()[j]/2, 0*mm, 0*mm ) ;
02727          
02728          cpv.position( pLog,
02729                 patchPanelName(), 
02730                 copyOne, 
02731                 pTra,
02732                 DDRotation() ) ;
02733          
02734          pTra += DDTranslation( vecPatchPanelThick()[j]/2, 0*mm, 0*mm ) ;
02735       }
02741 
02747 
02748       if( 0 != pincerRodHere() )
02749       {
02750          // Make hierarchy of rods, envelopes, blocks, shims, and cutouts
02751 
02752          DDSolid rodSolid ( DDSolidFactory::box( pincerRodName() ,
02753                                                  pincerEnvWidth()/2.,  
02754                                                  pincerEnvHeight()/2.,
02755                                                  ilyLength/2   ) ) ;
02756          const DDLogicalPart rodLog ( pincerRodName(), pincerRodMat(), rodSolid ) ;
02757 
02758          DDSolid envSolid ( DDSolidFactory::box( pincerEnvName() ,
02759                                                  pincerEnvWidth()/2.,  
02760                                                  pincerEnvHeight()/2.,
02761                                                  pincerEnvLength()/2   ) ) ;
02762          const DDLogicalPart envLog ( pincerEnvName(), pincerEnvMat(), envSolid ) ;
02763          const std::vector<double>& envParms ( envSolid.parameters() ) ;
02764 
02765          DDSolid blkSolid ( DDSolidFactory::box( pincerBlkName() ,
02766                                                  pincerEnvWidth()/2.,  
02767                                                  pincerEnvHeight()/2.,
02768                                                  pincerBlkLength()/2   ) ) ;
02769          const DDLogicalPart blkLog ( pincerBlkName(), pincerBlkMat(), blkSolid ) ;
02770          const std::vector<double>& blkParms ( blkSolid.parameters() ) ;
02771          cpv.position( blkLog,
02772                 pincerEnvName(), 
02773                 copyOne,
02774                 DDTranslation(0,0, pincerEnvLength()/2 - pincerBlkLength()/2 ),
02775                 DDRotation() ) ;
02776 
02777          DDSolid cutSolid ( DDSolidFactory::box( pincerCutName() ,
02778                                                  pincerCutWidth()/2.,  
02779                                                  pincerCutHeight()/2.,
02780                                                  pincerBlkLength()/2   ) ) ;
02781          const DDLogicalPart cutLog ( pincerCutName(), pincerCutMat(), cutSolid ) ;
02782          const std::vector<double>& cutParms ( cutSolid.parameters() ) ;
02783          cpv.position( cutLog,
02784                 pincerBlkName(), 
02785                 copyOne,
02786                 DDTranslation( +blkParms[0] - cutParms[0] - pincerShim1Width() + pincerShim2Width(),
02787                                -blkParms[1] + cutParms[1],     0  ),
02788                 DDRotation() ) ;
02789 
02790          DDSolid shim2Solid ( DDSolidFactory::box( pincerShim2Name() ,
02791                                                    pincerShim2Width()/2.,  
02792                                                    pincerShimHeight()/2.,
02793                                                    pincerBlkLength()/2   ) ) ;
02794          const DDLogicalPart shim2Log ( pincerShim2Name(), pincerShimMat(), shim2Solid ) ;
02795          const std::vector<double>& shim2Parms ( shim2Solid.parameters() ) ;
02796          cpv.position( shim2Log,
02797                 pincerCutName(), 
02798                 copyOne,
02799                 DDTranslation( +cutParms[0] - shim2Parms[0],
02800                                -cutParms[1] + shim2Parms[1],     0  ),
02801                 DDRotation() ) ;
02802 
02803          DDSolid shim1Solid ( DDSolidFactory::box( pincerShim1Name() ,
02804                                                    pincerShim1Width()/2.,  
02805                                                    pincerShimHeight()/2.,
02806                                                    (pincerEnvLength()-
02807                                                     pincerBlkLength())/2   ) ) ;
02808 
02809          const DDLogicalPart shim1Log ( pincerShim1Name(), pincerShimMat(), shim1Solid ) ;
02810          const std::vector<double>& shim1Parms ( shim1Solid.parameters() ) ;
02811          cpv.position( shim1Log,
02812                 pincerEnvName(), 
02813                 copyOne,
02814                 DDTranslation( +envParms[0] - shim1Parms[0],
02815                                -envParms[1] + shim1Parms[1],
02816                                -envParms[2] + shim1Parms[2] ),
02817                 DDRotation() ) ;
02818 
02819          for( unsigned int iEnv ( 0 ) ; iEnv != vecPincerEnvZOff().size() ; ++iEnv )
02820          {
02821             cpv.position( envLog,
02822                    pincerRodName(), 
02823                    1+iEnv, 
02824                    DDTranslation(0,0, -ilyLength/2. + vecPincerEnvZOff()[iEnv] - pincerEnvLength()/2. ),
02825                    DDRotation() ) ;
02826          }
02827 
02828          // Place the rods
02829 //       const double radius ( fawRadOff() - pincerEnvHeight()/2 -1*mm ) ;
02830          const double radius ( ilyRMin - pincerEnvHeight()/2 - 1*mm ) ;
02831 
02832          const DDName        xilyName    ( ddname( ilyName() +
02833                                                    int_to_string(vecIlyMat().size()-1) ) ) ;
02834 
02835          for( unsigned int iRod ( 0 ) ; iRod != vecPincerRodAzimuth().size() ; ++iRod )
02836          {
02837            const DDTranslation rodTra ( radius*cos(vecPincerRodAzimuth()[iRod]) ,
02838                                         radius*sin(vecPincerRodAzimuth()[iRod]) ,
02839                                         0 ) ;
02840            
02841            cpv.position( rodLog,
02842                   xilyName, 
02843                   1+iRod, 
02844                   rodTra,
02845                   myrot( pincerRodName().name() + int_to_string(iRod),
02846                          CLHEP::HepRotationZ( 90*deg + vecPincerRodAzimuth()[iRod] ) ) ) ;
02847          }
02848       }
02854 
02855       }
02856    } 
02857 
02858    LogDebug("EcalGeom") << "******** DDEcalBarrelAlgo test: end it..." ;
02859 }
02860 
02862 DDRotation
02863 DDEcalBarrelNewAlgo::myrot( const std::string&      s,
02864                          const CLHEP::HepRotation& r ) const 
02865 {
02866   return DDrot( ddname( m_idNameSpace + ":" + s ), new DDRotationMatrix( r.xx(), r.xy(), r.xz(), r.yx(), r.yy(), r.yz(), r.zx(), r.zy(), r.zz() ) ) ; 
02867 }
02868 
02869  
02870 DDMaterial
02871 DDEcalBarrelNewAlgo::ddmat( const std::string& s ) const
02872 {
02873    return DDMaterial( ddname( s ) ) ; 
02874 }
02875 
02876 DDName
02877 DDEcalBarrelNewAlgo::ddname( const std::string& s ) const
02878 { 
02879    const pair<std::string,std::string> temp ( DDSplit(s) ) ;
02880    if ( temp.second == "" ) {
02881      return DDName( temp.first,
02882                     m_idNameSpace ) ;
02883    } else {
02884      return DDName( temp.first, temp.second );
02885    } 
02886 }  
02887 
02888 DDSolid    
02889 DDEcalBarrelNewAlgo::mytrap( const std::string& s,
02890                           const EcalTrapezoidParameters& t ) const
02891 {
02892    return DDSolidFactory::trap( ddname( s ),
02893                                 t.dz(), 
02894                                 t.theta(), 
02895                                 t.phi(), 
02896                                 t.h1(), 
02897                                 t.bl1(), 
02898                                 t.tl1(),
02899                                 t.alp1(), 
02900                                 t.h2(), 
02901                                 t.bl2(), 
02902                                 t.tl2(), 
02903                                 t.alp2()         ) ;
02904 }
02905 
02906 void 
02907 DDEcalBarrelNewAlgo::web( unsigned int        iWeb,
02908                        double              bWeb,
02909                        double              BWeb,
02910                        double              LWeb,
02911                        double              theta,
02912                        const HepGeom::Point3D<double> &   corner,
02913                        const DDLogicalPart logPar,
02914                        double&             zee,
02915                        double              side,
02916                        double              front,
02917                        double              delta,
02918                        DDCompactView&      cpv  )
02919 {
02920    const unsigned int copyOne (1) ;
02921 
02922    const double LWebx ( vecWebLength()[iWeb] ) ;
02923 
02924    const double BWebx ( bWeb + ( BWeb - bWeb )*LWebx/LWeb ) ;
02925 
02926    const double thick ( vecWebPlTh()[iWeb] + vecWebClrTh()[iWeb] ) ;
02927    const Trap trapWebClr (
02928       BWebx/2,        // A/2 
02929       bWeb/2,        // a/2
02930       bWeb/2,        // b/2
02931       thick/2,       // H/2
02932       thick/2,       // h/2
02933       LWebx/2,        // L/2
02934       90*deg,        // alfa1
02935       bWeb - BWebx ,  // x15
02936       0              // y15
02937       ) ;
02938    const DDName        webClrDDName ( webClrName() + int_to_string( iWeb ) ) ;
02939    const DDSolid       webClrSolid  ( mytrap( webClrDDName.name(), trapWebClr ) ) ;
02940    const DDLogicalPart webClrLog    ( webClrDDName, webClrMat(), webClrSolid ) ;
02941             
02942    const Trap trapWebPl (
02943       trapWebClr.A()/2,                     // A/2 
02944       trapWebClr.a()/2,                     // a/2
02945       trapWebClr.b()/2,                     // b/2
02946       vecWebPlTh()[iWeb]/2,                 // H/2
02947       vecWebPlTh()[iWeb]/2,                 // h/2
02948       trapWebClr.L()/2.,                    // L/2
02949       90*deg,                               // alfa1
02950       trapWebClr.b() - trapWebClr.B() ,     // x15
02951       0                                     // y15
02952       ) ;
02953    const DDName        webPlDDName  ( webPlName() + int_to_string( iWeb ) ) ;
02954    const DDSolid       webPlSolid   ( mytrap( webPlDDName.fullname(), trapWebPl ) ) ;
02955    const DDLogicalPart webPlLog     ( webPlDDName, webPlMat(), webPlSolid ) ;
02956 
02957    cpv.position( webPlLog,     // place plate inside clearance volume
02958           webClrDDName, 
02959           copyOne, 
02960           DDTranslation(0,0,0),
02961           DDRotation() ) ;
02962 
02963    const Trap::VertexList vWeb ( trapWebClr.vertexList() ) ;
02964 
02965    zee += trapWebClr.h()/sin(theta) ;
02966 
02967    const double beta ( theta + delta ) ;
02968 
02969    const double zWeb ( zee - front*cos(beta) + side*sin(beta) ) ;
02970    const double yWeb ( front*sin(beta) + side*cos(beta) ) ;
02971 
02972    const Pt3D wedge3 ( corner + Pt3D( 0, -yWeb, zWeb ) ) ;
02973    const Pt3D wedge2 ( wedge3 + Pt3D( 0,
02974                                       trapWebClr.h()*cos(theta),
02975                                       -trapWebClr.h()*sin(theta)  ) ) ;
02976    const Pt3D wedge1 ( wedge3 + Pt3D( trapWebClr.a(), 0, 0 ) ) ;
02977 
02978    LogDebug("EcalGeom")<<"trap1="<<vWeb[0]<<", trap2="<<vWeb[2]<<", trap3="<<vWeb[3] ;
02979 
02980    LogDebug("EcalGeom")<<"wedge1="<<wedge1<<", wedge2="<<wedge2<<", wedge3="<<wedge3 ;
02981 
02982    const Tf3D tForm ( vWeb[0], vWeb[2], vWeb[3],
02983                       wedge1,   wedge2, wedge3    ) ;
02984    
02985    if( 0 != webHere() )
02986       cpv.position( webClrLog,
02987              logPar, 
02988              copyOne, 
02989              DDTranslation(tForm.getTranslation().x(), tForm.getTranslation().y(), tForm.getTranslation().z()),
02990              myrot( webClrLog.name().name() + int_to_string( iWeb ),
02991                     tForm.getRotation() ) ) ;
02992 }