CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_3_1/src/Geometry/TrackerCommonData/plugins/DDTIBLayerAlgo.cc

Go to the documentation of this file.
00001 
00002 // File: DDTIBLayerAlgo.cc
00003 // Description: Makes a TIB layer and position the strings with a tilt angle
00005 
00006 #include <cmath>
00007 #include <algorithm>
00008 
00009 #include "FWCore/MessageLogger/interface/MessageLogger.h"
00010 #include "DetectorDescription/Base/interface/DDutils.h"
00011 #include "DetectorDescription/Core/interface/DDLogicalPart.h"
00012 #include "DetectorDescription/Core/interface/DDSolid.h"
00013 #include "DetectorDescription/Core/interface/DDMaterial.h"
00014 #include "DetectorDescription/Core/interface/DDCurrentNamespace.h"
00015 #include "DetectorDescription/Core/interface/DDSplit.h"
00016 #include "Geometry/TrackerCommonData/plugins/DDTIBLayerAlgo.h"
00017 #include "CLHEP/Units/GlobalPhysicalConstants.h"
00018 #include "CLHEP/Units/GlobalSystemOfUnits.h"
00019 
00020 
00021 DDTIBLayerAlgo::DDTIBLayerAlgo(): ribW(0),ribPhi(0) {
00022   LogDebug("TIBGeom") << "DDTIBLayerAlgo info: Creating an instance";
00023 }
00024 
00025 DDTIBLayerAlgo::~DDTIBLayerAlgo() {}
00026 
00027 void DDTIBLayerAlgo::initialize(const DDNumericArguments & nArgs,
00028                                 const DDVectorArguments & vArgs,
00029                                 const DDMapArguments & ,
00030                                 const DDStringArguments & sArgs,
00031                                 const DDStringVectorArguments & ) {
00032 
00033   idNameSpace  = DDCurrentNamespace::ns();
00034   genMat       = sArgs["GeneralMaterial"];
00035   DDName parentName = parent().name(); 
00036   LogDebug("TIBGeom") << "DDTIBLayerAlgo debug: Parent " << parentName 
00037                       << " NameSpace " << idNameSpace 
00038                       << " General Material " << genMat;
00039 
00040   detectorTilt = nArgs["DetectorTilt"];
00041   layerL       = nArgs["LayerL"];
00042 
00043   radiusLo     = nArgs["RadiusLo"];
00044   stringsLo    = int(nArgs["StringsLo"]);
00045   detectorLo   = sArgs["StringDetLoName"];
00046   LogDebug("TIBGeom") << "DDTIBLayerAlgo debug: Lower layer Radius " 
00047                       << radiusLo << " Number " << stringsLo << " String "
00048                       << detectorLo;
00049 
00050   radiusUp     = nArgs["RadiusUp"];
00051   stringsUp    = int(nArgs["StringsUp"]);
00052   detectorUp   = sArgs["StringDetUpName"];
00053   LogDebug("TIBGeom") << "DDTIBLayerAlgo debug: Upper layer Radius "
00054                       << radiusUp << " Number " << stringsUp << " String "
00055                       << detectorUp;
00056 
00057   cylinderT    = nArgs["CylinderThickness"];
00058   cylinderInR  = nArgs["CylinderInnerRadius"];
00059   cylinderMat  = sArgs["CylinderMaterial"];
00060   MFRingInR    = nArgs["MFRingInnerRadius"]; 
00061   MFRingOutR   = nArgs["MFRingOuterRadius"]; 
00062   MFRingT      = nArgs["MFRingThickness"];   
00063   MFRingDz     = nArgs["MFRingDeltaz"];      
00064   MFIntRingMat = sArgs["MFIntRingMaterial"];      
00065   MFExtRingMat = sArgs["MFExtRingMaterial"];      
00066 
00067   supportT     = nArgs["SupportThickness"];
00068 
00069   centMat      = sArgs["CentRingMaterial"];
00070   centRing1par = vArgs["CentRing1"];
00071   centRing2par = vArgs["CentRing2"];
00072 
00073   fillerMat    = sArgs["FillerMaterial"];
00074   fillerDz     = nArgs["FillerDeltaz"];
00075 
00076   ribMat       = sArgs["RibMaterial"];
00077   ribW         = vArgs["RibWidth"];
00078   ribPhi       = vArgs["RibPhi"];
00079   LogDebug("TIBGeom") << "DDTIBLayerAlgo debug: Cylinder Material/"
00080                       << "thickness " << cylinderMat << " " << cylinderT 
00081                       << " Rib Material " << ribMat << " at "
00082                       << ribW.size() << " positions with width/phi";
00083 
00084   for (unsigned int i = 0; i < ribW.size(); i++)
00085     LogDebug("TIBGeom") << "\tribW[" << i << "] = " <<  ribW[i] 
00086                         << "\tribPhi[" << i << "] = " << ribPhi[i]/CLHEP::deg;
00087   
00088   dohmCarrierPhiOff   = nArgs["DOHMCarrierPhiOffset"];
00089 
00090   dohmtoMF            = nArgs["DOHMtoMFDist"];
00091 
00092   dohmPrimName         = sArgs["StringDOHMPrimName"];
00093   dohmAuxName          = sArgs["StringDOHMAuxName"];
00094 
00095   dohmCarrierMaterial = sArgs["DOHMCarrierMaterial"];
00096   dohmCableMaterial   = sArgs["DOHMCableMaterial"];
00097   dohmPrimL           = nArgs["DOHMPRIMLength"];
00098   dohmPrimMaterial    = sArgs["DOHMPRIMMaterial"];
00099   dohmAuxL            = nArgs["DOHMAUXLength"];
00100   dohmAuxMaterial     = sArgs["DOHMAUXMaterial"];
00101   dohmListFW          = vArgs["DOHMListFW"];
00102   dohmListBW          = vArgs["DOHMListBW"];
00103   LogDebug("TIBGeom") << "DDTIBLayerAlgo debug: DOHM Primary "
00104                       << " Material " << dohmPrimMaterial << " Length " << dohmPrimL;
00105   LogDebug("TIBGeom") << "DDTIBLayerAlgo debug: DOHM Aux     "
00106                       << " Material " << dohmAuxMaterial << " Length " << dohmAuxL;
00107   for (unsigned int i=0; i<dohmListFW.size(); i++) {
00108     if (dohmListFW[i]>0.) LogDebug("TIBGeom") << "DOHM Primary at FW Position " << dohmListFW[i];
00109     if (dohmListFW[i]<0.) LogDebug("TIBGeom") << "DOHM Aux     at FW Position " << -dohmListFW[i];
00110   }
00111   for (unsigned int i=0; i<dohmListBW.size(); i++) {
00112     if (dohmListBW[i]>0.) LogDebug("TIBGeom") << "DOHM Primary at BW Position " << dohmListBW[i];
00113     if (dohmListBW[i]<0.) LogDebug("TIBGeom") << "DOHM Aux     at BW Position " << -dohmListBW[i];
00114   }
00115 
00116   //Pillar Material
00117   pillarMaterial        = sArgs["PillarMaterial"];
00118 
00119   // Internal Pillar Parameters
00120   fwIntPillarDz         = nArgs["FWIntPillarDz"];
00121   fwIntPillarDPhi       = nArgs["FWIntPillarDPhi"];
00122   fwIntPillarZ          = vArgs["FWIntPillarZ"];
00123   fwIntPillarPhi        = vArgs["FWIntPillarPhi"];
00124   bwIntPillarDz         = nArgs["BWIntPillarDz"];
00125   bwIntPillarDPhi       = nArgs["BWIntPillarDPhi"];
00126   bwIntPillarZ          = vArgs["BWIntPillarZ"];
00127   bwIntPillarPhi        = vArgs["BWIntPillarPhi"];
00128   LogDebug("TIBGeom") << "FW Internal Pillar [Dz, DPhi] " 
00129                       << fwIntPillarDz << ", " 
00130                       << fwIntPillarDPhi; 
00131   for (unsigned int i=0; i<fwIntPillarZ.size(); i++) {
00132     if( fwIntPillarPhi[i]>0. ) { 
00133       LogDebug("TIBGeom") << " at positions [z, phi] " 
00134                           << fwIntPillarZ[i] << " " << fwIntPillarPhi[i];
00135     }
00136   }
00137   LogDebug("TIBGeom") << "BW Internal Pillar [Dz, DPhi] " 
00138                       << bwIntPillarDz << ", " 
00139                       << bwIntPillarDPhi; 
00140   for (unsigned int i=0; i<bwIntPillarZ.size(); i++) {
00141     if( bwIntPillarPhi[i]>0. ) { 
00142       LogDebug("TIBGeom") << " at positions [z, phi] " 
00143                           << bwIntPillarZ[i] << " " << bwIntPillarPhi[i];
00144     }
00145   }
00146 
00147   // External Pillar Parameters
00148   fwExtPillarDz         = nArgs["FWExtPillarDz"];
00149   fwExtPillarDPhi       = nArgs["FWExtPillarDPhi"];
00150   fwExtPillarZ          = vArgs["FWExtPillarZ"];
00151   fwExtPillarPhi        = vArgs["FWExtPillarPhi"];
00152   bwExtPillarDz         = nArgs["BWExtPillarDz"];
00153   bwExtPillarDPhi       = nArgs["BWExtPillarDPhi"];
00154   bwExtPillarZ          = vArgs["BWExtPillarZ"];
00155   bwExtPillarPhi        = vArgs["BWExtPillarPhi"];
00156   LogDebug("TIBGeom") << "FW External Pillar [Dz, DPhi] " 
00157                       << fwExtPillarDz << ", " 
00158                       << fwExtPillarDPhi; 
00159   for (unsigned int i=0; i<fwExtPillarZ.size(); i++) {
00160     if( fwExtPillarPhi[i]>0. ) { 
00161       LogDebug("TIBGeom") << " at positions [z, phi] " 
00162                           << fwExtPillarZ[i] << " " << fwExtPillarPhi[i];
00163     }
00164   }
00165   LogDebug("TIBGeom") << "BW External Pillar [Dz, DPhi] " 
00166                       << bwExtPillarDz << ", " 
00167                       << bwExtPillarDPhi; 
00168   for (unsigned int i=0; i<bwExtPillarZ.size(); i++) {
00169     if( bwExtPillarPhi[i]>0. ) { 
00170       LogDebug("TIBGeom") << " at positions [z, phi] " 
00171                           << bwExtPillarZ[i] << " " << bwExtPillarPhi[i];
00172     }
00173   }
00174 }
00175 
00176 void DDTIBLayerAlgo::execute(DDCompactView& cpv) {
00177 
00178   LogDebug("TIBGeom") << "==>> Constructing DDTIBLayerAlgo...";
00179 
00180   DDName  parentName = parent().name(); 
00181   const std::string &idName = parentName.name();
00182 
00183   double rmin = MFRingInR;
00184   double rmax = MFRingOutR;
00185 
00186   DDSolid solid = DDSolidFactory::tubs(DDName(idName, idNameSpace), 0.5*layerL,
00187                                        rmin, rmax, 0, CLHEP::twopi);
00188 
00189   LogDebug("TIBGeom") << "DDTIBLayerAlgo test: "  
00190                       << DDName(idName,idNameSpace) << " Tubs made of " 
00191                       << genMat << " from 0 to " << CLHEP::twopi/CLHEP::deg 
00192                       << " with Rin " << rmin << " Rout " << rmax 
00193                       << " ZHalf " << 0.5*layerL;
00194 
00195   DDName matname(DDSplit(genMat).first, DDSplit(genMat).second);
00196   DDMaterial matter(matname);
00197   DDLogicalPart layer(solid.ddname(), matter, solid);
00198 
00199   //Internal layer first
00200   double rin  = rmin+MFRingT;
00201   //  double rout = 0.5*(radiusLo+radiusUp-cylinderT);
00202   double rout = cylinderInR;
00203   std::string name = idName + "Down";
00204   solid = DDSolidFactory::tubs(DDName(name, idNameSpace), 0.5*layerL,
00205                                rin, rout, 0, CLHEP::twopi);
00206   LogDebug("TIBGeom") << "DDTIBLayerAlgo test: " 
00207                       << DDName(name, idNameSpace) << " Tubs made of " 
00208                       << genMat << " from 0 to " << CLHEP::twopi/CLHEP::deg 
00209                       << " with Rin " << rin << " Rout " << rout 
00210                       << " ZHalf " << 0.5*layerL;
00211   DDLogicalPart layerIn(solid.ddname(), matter, solid);
00212  cpv.position(layerIn, layer, 1, DDTranslation(0.0, 0.0, 0.0), DDRotation());
00213   LogDebug("TIBGeom") << "DDTIBLayerAlgo test: " << layerIn.name()
00214                       << " number 1 positioned in " << layer.name()
00215                       << " at (0,0,0) with no rotation";
00216 
00217   double rposdet = radiusLo;
00218   double dphi    = CLHEP::twopi/stringsLo;
00219   DDName detIn(DDSplit(detectorLo).first, DDSplit(detectorLo).second);
00220   for (int n = 0; n < stringsLo; n++) {
00221     double phi    = (n+0.5)*dphi;
00222     double phix   = phi - detectorTilt + 90*CLHEP::deg;
00223     double phideg = phix/CLHEP::deg;
00224     DDRotation rotation;
00225     if (phideg != 0) {
00226       double theta  = 90*CLHEP::deg;
00227       double phiy   = phix + 90.*CLHEP::deg;
00228       std::string rotstr = idName + dbl_to_string(phideg*10.);
00229       rotation = DDRotation(DDName(rotstr, idNameSpace));
00230       if (!rotation) {
00231         LogDebug("TIBGeom") << "DDTIBLayerAlgo test: Creating a new "
00232                             << "rotation: "     << rotstr << "\t90., " 
00233                             << phix/CLHEP::deg << ", 90.,"
00234                             << phiy/CLHEP::deg << ", 0, 0";
00235         rotation = DDrot(DDName(rotstr, idNameSpace), theta, phix, theta, phiy,
00236                          0., 0.);
00237       }
00238     }
00239     DDTranslation trdet(rposdet*cos(phi), rposdet*sin(phi), 0);
00240    cpv.position(detIn, layerIn, n+1, trdet, rotation);
00241     LogDebug("TIBGeom") << "DDTIBLayerAlgo test " << detIn.name() 
00242                         << " number " << n+1 << " positioned in " 
00243                         << layerIn.name() << " at " << trdet << " with "
00244                         << rotation;
00245   }
00246 
00247   //Now the external layer
00248   rin  = cylinderInR + cylinderT;
00249   rout = rmax-MFRingT;
00250   name = idName + "Up";
00251   solid = DDSolidFactory::tubs(DDName(name, idNameSpace), 0.5*layerL,
00252                                rin, rout, 0, CLHEP::twopi);
00253   LogDebug("TIBGeom") << "DDTIBLayerAlgo test: " 
00254                       << DDName(name, idNameSpace) << " Tubs made of " 
00255                       << genMat << " from 0 to " << CLHEP::twopi/CLHEP::deg 
00256                       << " with Rin " << rin << " Rout " << rout
00257                       << " ZHalf " << 0.5*layerL;
00258   DDLogicalPart layerOut(solid.ddname(), matter, solid);
00259  cpv.position(layerOut, layer, 1, DDTranslation(0.0, 0.0, 0.0), DDRotation());
00260   LogDebug("TIBGeom") << "DDTIBLayerAlgo test: " << layerOut.name() 
00261                       << " number 1 positioned in " << layer.name() 
00262                       << " at (0,0,0) with no rotation";
00263 
00264   rposdet = radiusUp;
00265   dphi    = CLHEP::twopi/stringsUp;
00266   DDName detOut(DDSplit(detectorUp).first, DDSplit(detectorUp).second);
00267   for (int n = 0; n < stringsUp; n++) {
00268     double phi    = (n+0.5)*dphi;
00269     double phix   = phi - detectorTilt - 90*CLHEP::deg;
00270     double phideg = phix/CLHEP::deg;
00271     DDRotation rotation;
00272     if (phideg != 0) {
00273       double theta  = 90*CLHEP::deg;
00274       double phiy   = phix + 90.*CLHEP::deg;
00275       std::string rotstr = idName + dbl_to_string(phideg*10.);
00276       rotation = DDRotation(DDName(rotstr, idNameSpace));
00277       if (!rotation) {
00278         LogDebug("TIBGeom") << "DDTIBLayerAlgo test: Creating a new "
00279                             << "rotation: " << rotstr << "\t90., " 
00280                             << phix/CLHEP::deg << ", 90.,"
00281                             << phiy/CLHEP::deg << ", 0, 0";
00282         rotation = DDrot(DDName(rotstr, idNameSpace), theta, phix, theta, phiy,
00283                          0., 0.);
00284       }
00285     }
00286     DDTranslation trdet(rposdet*cos(phi), rposdet*sin(phi), 0);
00287    cpv.position(detOut, layerOut, n+1, trdet, rotation);
00288     LogDebug("TIBGeom") << "DDTIBLayerAlgo test " << detOut.name() 
00289                         << " number " << n+1 << " positioned in " 
00290                         << layerOut.name() << " at " << trdet << " with "
00291                         << rotation;
00292   }
00293 
00294   //
00295   // Inner cylinder, support wall and ribs
00296   //
00297   // External skins
00298   rin  = cylinderInR;
00299   rout = cylinderInR+cylinderT;
00300   name = idName + "Cylinder";
00301   solid = DDSolidFactory::tubs(DDName(name, idNameSpace), 0.5*layerL,
00302                                rin, rout, 0, CLHEP::twopi);
00303   LogDebug("TIBGeom") << "DDTIBLayerAlgo test: " 
00304                       << DDName(name, idNameSpace) << " Tubs made of " 
00305                       << cylinderMat << " from 0 to " 
00306                       << CLHEP::twopi/CLHEP::deg << " with Rin " << rin 
00307                       << " Rout " << rout << " ZHalf " << 0.5*layerL;
00308   matname = DDName(DDSplit(cylinderMat).first, DDSplit(cylinderMat).second);
00309   DDMaterial matcyl(matname);
00310   DDLogicalPart cylinder(solid.ddname(), matcyl, solid);
00311  cpv.position(cylinder, layer, 1, DDTranslation(0.0, 0.0, 0.0), DDRotation());
00312   LogDebug("TIBGeom") << "DDTIBLayerAlgo test: " << cylinder.name() 
00313                       << " number 1 positioned in " << layer.name()
00314                       << " at (0,0,0) with no rotation";
00315   //
00316   // inner part of the cylinder
00317   //
00318   rin  += supportT;
00319   rout -= supportT;
00320   name  = idName + "CylinderIn";
00321   solid = DDSolidFactory::tubs(DDName(name, idNameSpace), 0.5*layerL,
00322                                rin, rout, 0, CLHEP::twopi);
00323   LogDebug("TIBGeom") << "DDTIBLayerAlgo test: "
00324                       << DDName(name, idNameSpace) << " Tubs made of "
00325                       << genMat << " from 0 to " << CLHEP::twopi/CLHEP::deg 
00326                       << " with Rin " << rin << " Rout " << rout 
00327                       << " ZHalf " << 0.5*layerL;
00328   DDLogicalPart cylinderIn(solid.ddname(), matter, solid);
00329  cpv.position(cylinderIn, cylinder, 1, DDTranslation(0.0, 0.0, 0.0), DDRotation());
00330   LogDebug("TIBGeom") << "DDTIBLayerAlgo test: " << cylinderIn.name() 
00331                       << " number 1 positioned in " << cylinder.name() 
00332                       << " at (0,0,0) with no rotation";
00333   //
00334   // Filler Rings
00335   //
00336   matname = DDName(DDSplit(fillerMat).first, DDSplit(fillerMat).second);
00337   DDMaterial matfiller(matname);
00338   name = idName + "Filler";
00339   solid = DDSolidFactory::tubs(DDName(name, idNameSpace), fillerDz, rin, rout, 
00340                                0., CLHEP::twopi);
00341   LogDebug("TIBGeom") << "DDTIBLayerAlgo test: " 
00342                       << DDName(name, idNameSpace) << " Tubs made of " 
00343                       << fillerMat << " from " << 0. << " to "
00344                       << CLHEP::twopi/CLHEP::deg << " with Rin " << rin 
00345                       << " Rout " << rout << " ZHalf "  << fillerDz;
00346   DDLogicalPart cylinderFiller(solid.ddname(), matfiller, solid);
00347  cpv.position(cylinderFiller, cylinderIn, 1, DDTranslation(0.0, 0.0, 0.5*layerL-fillerDz), DDRotation());
00348  cpv.position(cylinderFiller, cylinderIn, 2, DDTranslation(0.0, 0.0,-0.5*layerL+fillerDz), DDRotation());
00349   LogDebug("TIBGeom") << "DDTIBLayerAlgo test " << cylinderFiller.name()
00350                       << " number 1" << " positioned in " 
00351                       << cylinderIn.name() << " at " << DDTranslation(0.0, 0.0, 0.5*layerL-fillerDz)
00352                       << " number 2" << " positioned in " 
00353                       << cylinderIn.name() << " at " << DDTranslation(0.0, 0.0,-0.5*layerL+fillerDz);
00354 
00355   //
00356   // Ribs
00357   //
00358   matname = DDName(DDSplit(ribMat).first, DDSplit(ribMat).second);
00359   DDMaterial matrib(matname);
00360   for (int i = 0; i < (int)(ribW.size()); i++) {
00361     name = idName + "Rib" + dbl_to_string(i);
00362     double width = 2.*ribW[i]/(rin+rout);
00363     double dz    = 0.5*layerL-2.*fillerDz;
00364     solid = DDSolidFactory::tubs(DDName(name, idNameSpace), dz, 
00365                                  rin+0.5*CLHEP::mm, rout-0.5*CLHEP::mm, 
00366                                  -0.5*width, width);
00367     LogDebug("TIBGeom") << "DDTIBLayerAlgo test: " 
00368                         << DDName(name, idNameSpace) << " Tubs made of " 
00369                         << ribMat << " from " << -0.5*width/CLHEP::deg <<" to "
00370                         << 0.5*width/CLHEP::deg << " with Rin " 
00371                         << rin+0.5*CLHEP::mm << " Rout " 
00372                         << rout-0.5*CLHEP::mm << " ZHalf "  << dz;
00373     DDLogicalPart cylinderRib(solid.ddname(), matrib, solid);
00374     double phix   = ribPhi[i];
00375     double phideg = phix/CLHEP::deg;
00376     DDRotation rotation;
00377     if (phideg != 0) {
00378       double theta  = 90*CLHEP::deg;
00379       double phiy   = phix + 90.*CLHEP::deg;
00380       std::string rotstr = idName + dbl_to_string(phideg*10.);
00381       rotation = DDRotation(DDName(rotstr, idNameSpace));
00382       if (!rotation) {
00383         LogDebug("TIBGeom") << "DDTIBLayerAlgo test: Creating a new "
00384                             << "rotation: "     << rotstr << "\t90., " 
00385                             << phix/CLHEP::deg << ", 90.," << phiy/CLHEP::deg 
00386                             << ", 0, 0";
00387         rotation = DDrot(DDName(rotstr, idNameSpace), theta, phix, theta, phiy,
00388                          0., 0.);
00389       }
00390     }
00391     DDTranslation tran(0, 0, 0);
00392    cpv.position(cylinderRib, cylinderIn, 1, tran, rotation);
00393     LogDebug("TIBGeom") << "DDTIBLayerAlgo test " << cylinderRib.name()
00394                         << " number 1" << " positioned in " 
00395                         << cylinderIn.name() << " at " << tran << " with " 
00396                         << rotation;
00397   }
00398 
00399   //Manifold rings
00400   //
00401   // Inner ones first
00402   matname = DDName(DDSplit(MFIntRingMat).first, DDSplit(MFIntRingMat).second);
00403   DDMaterial matintmfr(matname);
00404   rin  = MFRingInR;
00405   rout = rin + MFRingT;
00406   name = idName + "InnerMFRing";
00407   solid = DDSolidFactory::tubs(DDName(name, idNameSpace), MFRingDz,
00408                                rin, rout, 0, CLHEP::twopi);
00409 
00410   LogDebug("TIBGeom") << "DDTIBLayerAlgo test: " 
00411                       << DDName(name, idNameSpace) << " Tubs made of " 
00412                       << MFIntRingMat << " from 0 to " 
00413                       << CLHEP::twopi/CLHEP::deg << " with Rin " << rin 
00414                       << " Rout " << rout << " ZHalf " << MFRingDz;
00415 
00416   DDLogicalPart inmfr(solid.ddname(), matintmfr, solid);
00417  cpv.position(inmfr, layer, 1, DDTranslation(0.0, 0.0, -0.5*layerL+MFRingDz), DDRotation());
00418  cpv.position(inmfr, layer, 2, DDTranslation(0.0, 0.0, +0.5*layerL-MFRingDz), DDRotation());
00419   LogDebug("TIBGeom") << "DDTIBLayerAlgo test: " << inmfr.name() 
00420                       << " number 1 and 2 positioned in " << layer.name()
00421                       << " at (0,0,+-" << 0.5*layerL-MFRingDz << ") with no rotation";
00422   // Outer ones
00423   matname = DDName(DDSplit(MFExtRingMat).first, DDSplit(MFExtRingMat).second);
00424   DDMaterial matextmfr(matname);
00425   rout  = MFRingOutR;
00426   rin   = rout - MFRingT;
00427   name = idName + "OuterMFRing";
00428   solid = DDSolidFactory::tubs(DDName(name, idNameSpace), MFRingDz,
00429                                rin, rout, 0, CLHEP::twopi);
00430 
00431   LogDebug("TIBGeom") << "DDTIBLayerAlgo test: " 
00432                       << DDName(name, idNameSpace) << " Tubs made of " 
00433                       << MFExtRingMat << " from 0 to " 
00434                       << CLHEP::twopi/CLHEP::deg << " with Rin " << rin 
00435                       << " Rout " << rout << " ZHalf " << MFRingDz;
00436 
00437   DDLogicalPart outmfr(solid.ddname(), matextmfr, solid);
00438  cpv.position(outmfr, layer, 1, DDTranslation(0.0, 0.0, -0.5*layerL+MFRingDz), DDRotation());
00439  cpv.position(outmfr, layer, 2, DDTranslation(0.0, 0.0, +0.5*layerL-MFRingDz), DDRotation());
00440   LogDebug("TIBGeom") << "DDTIBLayerAlgo test: " << outmfr.name() 
00441                       << " number 1 and 2 positioned in " << layer.name()
00442                       << " at (0,0,+-" << 0.5*layerL-MFRingDz 
00443                       << ") with no rotation";
00444 
00445   //Central Support rings
00446   //
00447   matname = DDName(DDSplit(centMat).first, DDSplit(centMat).second);
00448   DDMaterial matcent(matname);
00449   // Ring 1
00450   double centZ  = centRing1par[0];
00451   double centDz = 0.5*centRing1par[1];
00452   rin  = centRing1par[2];
00453   rout = centRing1par[3];
00454   name = idName + "CentRing1";
00455   solid = DDSolidFactory::tubs(DDName(name, idNameSpace), centDz,
00456                                rin, rout, 0, CLHEP::twopi);
00457 
00458   LogDebug("TIBGeom") << "DDTIBLayerAlgo test: " 
00459                       << DDName(name, idNameSpace) << " Tubs made of " 
00460                       << centMat << " from 0 to " << CLHEP::twopi/CLHEP::deg 
00461                       << " with Rin " << rin << " Rout " << rout 
00462                       << " ZHalf " << centDz;
00463 
00464   DDLogicalPart cent1(solid.ddname(), matcent, solid);
00465  cpv.position(cent1, layer, 1, DDTranslation(0.0, 0.0, centZ), DDRotation());
00466   LogDebug("TIBGeom") << "DDTIBLayerAlgo test: " << cent1.name() 
00467                       << " positioned in " << layer.name()
00468                       << " at (0,0," << centZ << ") with no rotation";
00469   // Ring 2
00470   centZ  = centRing2par[0];
00471   centDz = 0.5*centRing2par[1];
00472   rin  = centRing2par[2];
00473   rout = centRing2par[3];
00474   name = idName + "CentRing2";
00475   solid = DDSolidFactory::tubs(DDName(name, idNameSpace), centDz,
00476                                rin, rout, 0, CLHEP::twopi);
00477 
00478   LogDebug("TIBGeom") << "DDTIBLayerAlgo test: " 
00479                       << DDName(name, idNameSpace) << " Tubs made of " 
00480                       << centMat << " from 0 to " << CLHEP::twopi/CLHEP::deg 
00481                       << " with Rin " << rin << " Rout " << rout 
00482                       << " ZHalf " << centDz;
00483 
00484   DDLogicalPart cent2(solid.ddname(), matcent, solid);
00485  cpv.position(cent2, layer, 1, DDTranslation(0.0, 0.0, centZ), DDRotation());
00486   LogDebug("TIBGeom") << "DDTIBLayerAlgo test: " << cent2.name() 
00487                       << " positioned in " << layer.name()
00488                       << " at (0,0," << centZ << ") with no rotation";
00489 
00491   //
00492   // Preparing DOHM Carrier solid
00493 
00494   name = idName + "DOHMCarrier";
00495 
00496   double dohmCarrierRin   = MFRingOutR - MFRingT;
00497   double dohmCarrierRout  = MFRingOutR;
00498   double dohmCarrierDz    = 0.5*(dohmPrimL+dohmtoMF);
00499   double dohmCarrierZ     = 0.5*layerL-2.*MFRingDz-dohmCarrierDz;
00500 
00501   solid = DDSolidFactory::tubs(DDName(name, idNameSpace), dohmCarrierDz, 
00502                                dohmCarrierRin, dohmCarrierRout, 
00503                                dohmCarrierPhiOff, 
00504                                180.*CLHEP::deg-2.*dohmCarrierPhiOff);
00505   LogDebug("TIBGeom") << "DDTIBLayerAlgo test: " 
00506                       << DDName(name, idNameSpace) << " Tubs made of "
00507                       << dohmCarrierMaterial << " from "
00508                       << dohmCarrierPhiOff << " to " 
00509                       << 180.*CLHEP::deg-dohmCarrierPhiOff << " with Rin "
00510                       << dohmCarrierRin << " Rout " << MFRingOutR << " ZHalf " 
00511                       << dohmCarrierDz;
00512 
00513 
00514   // Define FW and BW carrier logical volume and
00515   // place DOHM Primary and auxiliary modules inside it
00516 
00517   dphi = CLHEP::twopi/stringsUp;
00518 
00519   DDRotation dohmRotation;
00520 
00521   double dohmR = 0.5*(dohmCarrierRin+dohmCarrierRout);
00522 
00523 
00524   for (int j = 0; j<4; j++) {
00525 
00526     std::vector<double> dohmList;
00527     DDTranslation tran;
00528     std::string rotstr;
00529     DDRotation rotation;
00530     int dohmCarrierReplica=0;
00531     int placeDohm = 0;
00532 
00533     switch (j){
00534     case 0:
00535       name = idName + "DOHMCarrierFW";
00536       dohmList = dohmListFW;
00537       tran = DDTranslation(0., 0., dohmCarrierZ);
00538       rotstr = idName + "FwUp";
00539       rotation = DDRotation();
00540       dohmCarrierReplica = 1;
00541       placeDohm=1;
00542       break;
00543     case 1:
00544       name = idName + "DOHMCarrierFW";
00545       dohmList = dohmListFW;
00546       tran = DDTranslation(0., 0., dohmCarrierZ);
00547       rotstr = idName + "FwDown";
00548       rotation = DDrot(DDName(rotstr, idNameSpace), 90.*CLHEP::deg, 
00549                        180.*CLHEP::deg, 90.*CLHEP::deg,270.*CLHEP::deg, 0.,0.);
00550       dohmCarrierReplica = 2;
00551       placeDohm=0;
00552       break;
00553     case 2:
00554       name = idName + "DOHMCarrierBW";
00555       dohmList = dohmListBW;
00556       tran = DDTranslation(0., 0., -dohmCarrierZ);
00557       rotstr = idName + "BwUp";
00558       rotation = DDrot(DDName(rotstr, idNameSpace), 90.*CLHEP::deg, 
00559                        180.*CLHEP::deg, 90.*CLHEP::deg, 90.*CLHEP::deg, 
00560                        180.*CLHEP::deg, 0.);
00561       dohmCarrierReplica = 1;
00562       placeDohm=1;
00563       break;
00564     case 3:
00565       name = idName + "DOHMCarrierBW";
00566       dohmList = dohmListBW;
00567       tran = DDTranslation(0., 0., -dohmCarrierZ);
00568       rotstr = idName + "BwDown";
00569       rotation = DDrot(DDName(rotstr, idNameSpace), 90.*CLHEP::deg, 0., 
00570                        90.*CLHEP::deg, 270.*CLHEP::deg, 180.*CLHEP::deg, 0.);
00571       dohmCarrierReplica = 2;
00572       placeDohm=0;
00573       break;
00574     }
00575 
00576     DDLogicalPart dohmCarrier(name,DDMaterial(dohmCarrierMaterial),solid);
00577 
00578     int primReplica = 0;
00579     int auxReplica = 0;
00580 
00581     for (int i = 0; i < placeDohm*((int)(dohmList.size())); i++) {
00582 
00583       double phi    = (std::abs(dohmList[i])+0.5-1.)*dphi;
00584       double phix   = phi + 90*CLHEP::deg;
00585       double phideg = phix/CLHEP::deg;
00586       if (phideg != 0) {
00587         double theta  = 90*CLHEP::deg;
00588         double phiy   = phix + 90.*CLHEP::deg;
00589         std::string   rotstr = idName+dbl_to_string(std::abs(dohmList[i])-1.);
00590         dohmRotation = DDRotation(DDName(rotstr, idNameSpace));
00591         if (!dohmRotation) {
00592           LogDebug("TIBGeom") << "DDTIBLayerAlgo test: Creating a new "
00593                               << "rotation: "   << rotstr << "\t" << theta 
00594                               << ", " << phix/CLHEP::deg << ", " << theta 
00595                               << ", " << phiy/CLHEP::deg <<", 0, 0";
00596           dohmRotation = DDrot(DDName(rotstr, idNameSpace), theta, phix, theta,
00597                                phiy, 0., 0.);
00598         }
00599       }
00600       
00601       std::string dohmName;
00602       int dohmReplica = 0;
00603       double dohmZ = 0.;
00604       
00605       if(dohmList[i]<0.) {
00606         // Place a Auxiliary DOHM
00607         dohmName = dohmAuxName;
00608         dohmZ = dohmCarrierDz - 0.5*dohmAuxL - dohmtoMF;
00609         primReplica++;
00610         dohmReplica = primReplica;
00611         
00612       } else {
00613         // Place a Primary DOHM
00614         dohmName = dohmPrimName;
00615         dohmZ = dohmCarrierDz - 0.5*dohmPrimL - dohmtoMF;
00616         auxReplica++;
00617         dohmReplica = auxReplica;
00618       }
00619       
00620       DDName dohm(DDSplit(dohmName).first, DDSplit(dohmName).second);
00621       DDTranslation dohmTrasl(dohmR*cos(phi), dohmR*sin(phi), dohmZ);
00622      cpv.position(dohm, dohmCarrier, dohmReplica, dohmTrasl, dohmRotation);
00623       LogDebug("TIBGeom") << "DDTIBLayerAlgo test " << dohm.name() 
00624                           << " replica " << dohmReplica << " positioned in " 
00625                           << dohmCarrier.name() << " at " << dohmTrasl << " with "
00626                           << dohmRotation;
00627       
00628     }
00629     
00630     
00631    cpv.position(dohmCarrier, parent(), dohmCarrierReplica, tran, rotation );
00632     LogDebug("TIBGeom") << "DDTIBLayerAlgo test "
00633                         << dohmCarrier.name() << " positioned in " << parent().name() << " at "
00634                         << tran << " with " << rotation;
00635     
00636   }
00637 
00639 
00640   for (int j = 0; j<4; j++) {
00641     
00642     matname = DDName(DDSplit(pillarMaterial).first, DDSplit(pillarMaterial).second);
00643     DDMaterial pillarMat(matname);
00644     std::vector<double> pillarZ;
00645     std::vector<double> pillarPhi;
00646     double pillarDz=0, pillarDPhi=0, pillarRin=0, pillarRout=0;
00647     
00648     switch (j){
00649     case 0:
00650       name = idName + "FWIntPillar";
00651       pillarZ    = fwIntPillarZ;
00652       pillarPhi  = fwIntPillarPhi;
00653       pillarRin  = MFRingInR;
00654       pillarRout = MFRingInR + MFRingT;
00655       pillarDz   = fwIntPillarDz;
00656       pillarDPhi = fwIntPillarDPhi;
00657       break;
00658     case 1:
00659       name = idName + "BWIntPillar";
00660       pillarZ    = bwIntPillarZ;
00661       pillarPhi  = bwIntPillarPhi;
00662       pillarRin  = MFRingInR;
00663       pillarRout = MFRingInR + MFRingT;
00664       pillarDz   = bwIntPillarDz;
00665       pillarDPhi = bwIntPillarDPhi;
00666       break;
00667     case 2:
00668       name = idName + "FWExtPillar";
00669       pillarZ    = fwExtPillarZ;
00670       pillarPhi  = fwExtPillarPhi;
00671       pillarRin  = MFRingOutR - MFRingT;
00672       pillarRout = MFRingOutR;
00673       pillarDz   = fwExtPillarDz;
00674       pillarDPhi = fwExtPillarDPhi;
00675       break;
00676     case 3:
00677       name = idName + "BWExtPillar";
00678       pillarZ    = bwExtPillarZ;
00679       pillarPhi  = bwExtPillarPhi;
00680       pillarRin  = MFRingOutR - MFRingT;
00681       pillarRout = MFRingOutR;
00682       pillarDz   = bwExtPillarDz;
00683       pillarDPhi = bwExtPillarDPhi;
00684       break;
00685     }
00686     
00687     
00688     solid = DDSolidFactory::tubs(DDName(name, idNameSpace), pillarDz, 
00689                                  pillarRin, pillarRout, 
00690                                  -pillarDPhi, 2.*pillarDPhi);
00691     
00692     DDLogicalPart Pillar(name,DDMaterial(pillarMat),solid);
00693     
00694     LogDebug("TIBGeom") << "DDTIBLayerAlgo test: " 
00695                         << DDName(name, idNameSpace) << " Tubs made of "
00696                         << pillarMat << " from "
00697                         << -pillarDPhi << " to " 
00698                         << pillarDPhi << " with Rin "
00699                         << pillarRin << " Rout " << pillarRout << " ZHalf "  
00700                         << pillarDz;
00701     
00702     DDTranslation pillarTran;
00703     DDRotation pillarRota;
00704     int pillarReplica = 0;
00705     for (unsigned int i=0; i<pillarZ.size(); i++) {
00706       if( pillarPhi[i]>0. ) {
00707         
00708         pillarTran = DDTranslation(0., 0., pillarZ[i]);
00709         pillarRota = DDanonymousRot(DDcreateRotationMatrix(90.*CLHEP::deg, pillarPhi[i], 90.*CLHEP::deg, 90.*CLHEP::deg+pillarPhi[i], 0., 0.));
00710         
00711         cpv.position(Pillar, parent(), i, pillarTran, pillarRota);
00712         LogDebug("TIBGeom") << "DDTIBLayerAlgo test "
00713                             << Pillar.name() << " positioned in " 
00714                             << parent().name() << " at "
00715                             << pillarTran << " with " << pillarRota 
00716                             << " copy number " << pillarReplica;
00717         
00718         pillarReplica++;
00719       }
00720 
00721     }
00722     
00723   }
00724 
00725 }