Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:15:22

0001 #include "DD4hep/DetFactoryHelper.h"
0002 #include <DD4hep/DD4hepUnits.h>
0003 #include "DataFormats/Math/interface/angle_units.h"
0004 #include "DetectorDescription/DDCMS/interface/DDPlugins.h"
0005 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0006 
0007 using namespace std;
0008 using namespace dd4hep;
0009 using namespace cms;
0010 using namespace angle_units::operators;
0011 
0012 static long algorithm(Detector& /* description */, cms::DDParsingContext& context, xml_h element) {
0013   using VecDouble = vector<double>;
0014 
0015   cms::DDNamespace ns(context, element, true);
0016   DDAlgoArguments args(context, element);
0017 
0018   string mother = args.parentName();
0019   string genMat = args.str("GeneralMaterial");      //General material name
0020   double detectorTilt = args.dble("DetectorTilt");  //Detector Tilt
0021   double layerL = args.dble("LayerL");              //Length of the layer
0022 
0023   double radiusLo = args.dble("RadiusLo");          //Radius for detector at lower level
0024   int stringsLo = args.integer("StringsLo");        //Number of strings      ......
0025   string detectorLo = args.str("StringDetLoName");  //Detector string name   ......
0026 
0027   double radiusUp = args.dble("RadiusUp");          //Radius for detector at upper level
0028   int stringsUp = args.integer("StringsUp");        //Number of strings      ......
0029   string detectorUp = args.str("StringDetUpName");  //Detector string name   ......
0030 
0031   double cylinderT = args.dble("CylinderThickness");      //Cylinder thickness
0032   double cylinderInR = args.dble("CylinderInnerRadius");  //Cylinder inner radius
0033   string cylinderMat = args.str("CylinderMaterial");      //Cylinder material
0034   double MFRingInR = args.dble("MFRingInnerRadius");      //Inner Manifold Ring Inner Radius
0035   double MFRingOutR = args.dble("MFRingOuterRadius");     //Outer Manifold Ring Outer Radius
0036   double MFRingT = args.dble("MFRingThickness");          //Manifold Ring Thickness
0037   double MFRingDz = args.dble("MFRingDeltaz");            //Manifold Ring Half Lenght
0038   string MFIntRingMat = args.str("MFIntRingMaterial");    //Manifold Ring Material
0039   string MFExtRingMat = args.str("MFExtRingMaterial");    //Manifold Ring Material
0040 
0041   double supportT = args.dble("SupportThickness");  //Cylinder barrel CF skin thickness
0042 
0043   string centMat = args.str("CentRingMaterial");       //Central rings  material
0044   VecDouble centRing1par = args.vecDble("CentRing1");  //Central rings parameters
0045   VecDouble centRing2par = args.vecDble("CentRing2");  //Central rings parameters
0046 
0047   string fillerMat = args.str("FillerMaterial");  //Filler material
0048   double fillerDz = args.dble("FillerDeltaz");    //Filler Half Length
0049 
0050   string ribMat = args.str("RibMaterial");    //Rib material
0051   VecDouble ribW = args.vecDble("RibWidth");  //Rib width
0052   VecDouble ribPhi = args.vecDble("RibPhi");  //Rib Phi position
0053 
0054   VecDouble dohmListFW = args.vecDble("DOHMListFW");  //DOHM/AUX positions in #strings FW
0055   VecDouble dohmListBW = args.vecDble("DOHMListBW");  //DOHM/AUX positions in #strings BW
0056 
0057   double dohmtoMF = args.dble("DOHMtoMFDist");                   //DOHM Distance to MF
0058   double dohmCarrierPhiOff = args.dble("DOHMCarrierPhiOffset");  //DOHM Carrier Phi offset wrt horizontal
0059   string dohmPrimName = args.str("StringDOHMPrimName");          //DOHM Primary Logical Volume name
0060   string dohmAuxName = args.str("StringDOHMAuxName");            //DOHM Auxiliary Logical Volume name
0061 
0062   string dohmCarrierMaterial = args.str("DOHMCarrierMaterial");  //DOHM Carrier Material
0063   string dohmCableMaterial = args.str("DOHMCableMaterial");      //DOHM Cable Material
0064   double dohmPrimL = args.dble("DOHMPRIMLength");                //DOHM PRIMary Length
0065   string dohmPrimMaterial = args.str("DOHMPRIMMaterial");        //DOHM PRIMary Material
0066   double dohmAuxL = args.dble("DOHMAUXLength");                  //DOHM AUXiliary Length
0067   string dohmAuxMaterial = args.str("DOHMAUXMaterial");          //DOHM AUXiliary Material
0068 
0069   string pillarMaterial = args.str("PillarMaterial");  //Pillar Material
0070 
0071   double fwIntPillarDz = args.dble("FWIntPillarDz");  //Internal pillar parameters
0072   double fwIntPillarDPhi = args.dble("FWIntPillarDPhi");
0073   VecDouble fwIntPillarZ = args.vecDble("FWIntPillarZ");
0074   VecDouble fwIntPillarPhi = args.vecDble("FWIntPillarPhi");
0075   double bwIntPillarDz = args.dble("BWIntPillarDz");
0076   double bwIntPillarDPhi = args.dble("BWIntPillarDPhi");
0077   VecDouble bwIntPillarZ = args.vecDble("BWIntPillarZ");
0078   VecDouble bwIntPillarPhi = args.vecDble("BWIntPillarPhi");
0079 
0080   double fwExtPillarDz = args.dble("FWExtPillarDz");  //External pillar parameters
0081   double fwExtPillarDPhi = args.dble("FWExtPillarDPhi");
0082   VecDouble fwExtPillarZ = args.vecDble("FWExtPillarZ");
0083   VecDouble fwExtPillarPhi = args.vecDble("FWExtPillarPhi");
0084   double bwExtPillarDz = args.dble("BWExtPillarDz");
0085   double bwExtPillarDPhi = args.dble("BWExtPillarDPhi");
0086   VecDouble bwExtPillarZ = args.vecDble("BWExtPillarZ");
0087   VecDouble bwExtPillarPhi = args.vecDble("BWExtPillarPhi");
0088 
0089   dd4hep::PlacedVolume pv;
0090 
0091   auto LogPosition = [](dd4hep::PlacedVolume pvl) {
0092     edm::LogVerbatim("TIBGeom") << "DDTIBLayerAlgo: " << pvl.volume()->GetName()
0093                                 << " positioned: " << pvl.motherVol()->GetName() << " " << pvl.position();
0094   };
0095 
0096   edm::LogVerbatim("TIBGeom") << "Parent " << mother << " NameSpace " << ns.name() << " General Material " << genMat;
0097   edm::LogVerbatim("TIBGeom") << "Lower layer Radius " << radiusLo << " Number " << stringsLo << " String "
0098                               << detectorLo;
0099   edm::LogVerbatim("TIBGeom") << "Upper layer Radius " << radiusUp << " Number " << stringsUp << " String "
0100                               << detectorUp;
0101   edm::LogVerbatim("TIBGeom") << "Cylinder Material/thickness " << cylinderMat << " " << cylinderT << " Rib Material "
0102                               << ribMat << " at " << ribW.size() << " positions with width/phi";
0103   for (unsigned int i = 0; i < ribW.size(); i++) {
0104     edm::LogVerbatim("TIBGeom") << "\tribW[" << i << "] = " << ribW[i] << "\tribPhi[" << i
0105                                 << "] = " << convertRadToDeg(ribPhi[i]);
0106   }
0107   edm::LogVerbatim("TIBGeom") << "DOHM Primary "
0108                               << " Material " << dohmPrimMaterial << " Length " << dohmPrimL;
0109   edm::LogVerbatim("TIBGeom") << "DOHM Aux     "
0110                               << " Material " << dohmAuxMaterial << " Length " << dohmAuxL;
0111   for (double i : dohmListFW) {
0112     if (i > 0.)
0113       edm::LogVerbatim("TIBGeom") << "DOHM Primary at FW Position " << i;
0114     if (i < 0.)
0115       edm::LogVerbatim("TIBGeom") << "DOHM Aux     at FW Position " << -i;
0116   }
0117   for (double i : dohmListBW) {
0118     if (i > 0.)
0119       edm::LogVerbatim("TIBGeom") << "DOHM Primary at BW Position " << i;
0120     if (i < 0.)
0121       edm::LogVerbatim("TIBGeom") << "DOHM Aux     at BW Position " << -i;
0122   }
0123   edm::LogVerbatim("TIBGeom") << "FW Internal Pillar [Dz, DPhi] " << fwIntPillarDz << ", " << fwIntPillarDPhi;
0124   for (unsigned int i = 0; i < fwIntPillarZ.size(); i++) {
0125     if (fwIntPillarPhi[i] > 0.) {
0126       edm::LogVerbatim("TIBGeom") << " at positions [z, phi] " << fwIntPillarZ[i] << " " << fwIntPillarPhi[i];
0127     }
0128   }
0129   edm::LogVerbatim("TIBGeom") << "BW Internal Pillar [Dz, DPhi] " << bwIntPillarDz << ", " << bwIntPillarDPhi;
0130   for (unsigned int i = 0; i < bwIntPillarZ.size(); i++) {
0131     if (bwIntPillarPhi[i] > 0.) {
0132       edm::LogVerbatim("TIBGeom") << " at positions [z, phi] " << bwIntPillarZ[i] << " " << bwIntPillarPhi[i];
0133     }
0134   }
0135   edm::LogVerbatim("TIBGeom") << "FW External Pillar [Dz, DPhi] " << fwExtPillarDz << ", " << fwExtPillarDPhi;
0136   for (unsigned int i = 0; i < fwExtPillarZ.size(); i++) {
0137     if (fwExtPillarPhi[i] > 0.) {
0138       edm::LogVerbatim("TIBGeom") << " at positions [z, phi] " << fwExtPillarZ[i] << " " << fwExtPillarPhi[i];
0139     }
0140   }
0141   edm::LogVerbatim("TIBGeom") << "BW External Pillar [Dz, DPhi] " << bwExtPillarDz << ", " << bwExtPillarDPhi;
0142   for (unsigned int i = 0; i < bwExtPillarZ.size(); i++) {
0143     if (bwExtPillarPhi[i] > 0.) {
0144       edm::LogVerbatim("TIBGeom") << " at positions [z, phi] " << bwExtPillarZ[i] << " " << bwExtPillarPhi[i];
0145     }
0146   }
0147 
0148   const string& idName = mother;
0149   double rmin = MFRingInR;
0150   double rmax = MFRingOutR;
0151   Solid solid = ns.addSolidNS(ns.prepend(idName), Tube(rmin, rmax, 0.5 * layerL));
0152   edm::LogVerbatim("TIBGeom") << solid.name() << " Tubs made of " << genMat << " from 0 to " << convertRadToDeg(2_pi)
0153                               << " with Rin " << rmin << " Rout " << rmax << " ZHalf " << 0.5 * layerL;
0154   Volume layer = ns.addVolumeNS(Volume(ns.prepend(idName), solid, ns.material(genMat)));
0155 
0156   //Internal layer first
0157   double rin = rmin + MFRingT;
0158   //  double rout = 0.5*(radiusLo+radiusUp-cylinderT);
0159   double rout = cylinderInR;
0160   string name = idName + "Down";
0161   solid = ns.addSolidNS(ns.prepend(name), Tube(rin, rout, 0.5 * layerL));
0162   edm::LogVerbatim("TIBGeom") << solid.name() << " Tubs made of " << genMat << " from 0 to " << convertRadToDeg(2_pi)
0163                               << " with Rin " << rin << " Rout " << rout << " ZHalf " << 0.5 * layerL;
0164   Volume layerIn = ns.addVolumeNS(Volume(ns.prepend(name), solid, ns.material(genMat)));
0165   pv = layer.placeVolume(layerIn, 1);
0166   LogPosition(pv);
0167 
0168   double rposdet = radiusLo;
0169   double dphi = 2_pi / stringsLo;
0170   Volume detIn = ns.volume(detectorLo);
0171   for (int n = 0; n < stringsLo; n++) {
0172     double phi = (n + 0.5) * dphi;
0173     double phix = phi - detectorTilt + 90_deg;
0174     double theta = 90_deg;
0175     double phiy = phix + 90._deg;
0176     Rotation3D rotation = makeRotation3D(theta, phix, theta, phiy, 0., 0.);
0177     Position trdet(rposdet * cos(phi), rposdet * sin(phi), 0);
0178     pv = layerIn.placeVolume(detIn, n + 1, Transform3D(rotation, trdet));
0179     LogPosition(pv);
0180   }
0181   //Now the external layer
0182   rin = cylinderInR + cylinderT;
0183   rout = rmax - MFRingT;
0184   name = idName + "Up";
0185   solid = ns.addSolidNS(ns.prepend(name), Tube(rin, rout, 0.5 * layerL));
0186   edm::LogVerbatim("TIBGeom") << solid.name() << " Tubs made of " << genMat << " from 0 to " << convertRadToDeg(2_pi)
0187                               << " with Rin " << rin << " Rout " << rout << " ZHalf " << 0.5 * layerL;
0188   Volume layerOut = ns.addVolumeNS(Volume(ns.prepend(name), solid, ns.material(genMat)));
0189   pv = layer.placeVolume(layerOut, 1);
0190   LogPosition(pv);
0191 
0192   rposdet = radiusUp;
0193   dphi = 2_pi / stringsUp;
0194   Volume detOut = ns.volume(detectorUp);
0195   for (int n = 0; n < stringsUp; n++) {
0196     double phi = (n + 0.5) * dphi;
0197     double phix = phi - detectorTilt - 90_deg;
0198     double theta = 90_deg;
0199     double phiy = phix + 90._deg;
0200     Rotation3D rotation = makeRotation3D(theta, phix, theta, phiy, 0., 0.);
0201     Position trdet(rposdet * cos(phi), rposdet * sin(phi), 0);
0202     pv = layerOut.placeVolume(detOut, n + 1, Transform3D(rotation, trdet));
0203     LogPosition(pv);
0204   }
0205 
0206   //
0207   // Inner cylinder, support wall and ribs
0208   //
0209   // External skins
0210   rin = cylinderInR;
0211   rout = cylinderInR + cylinderT;
0212   name = idName + "Cylinder";
0213   solid = ns.addSolidNS(ns.prepend(name), Tube(rin, rout, 0.5 * layerL));
0214   edm::LogVerbatim("TIBGeom") << solid.name() << " Tubs made of " << cylinderMat << " from 0 to "
0215                               << convertRadToDeg(2_pi) << " with Rin " << rin << " Rout " << rout << " ZHalf "
0216                               << 0.5 * layerL;
0217   Volume cylinder = ns.addVolumeNS(Volume(ns.prepend(name), solid, ns.material(cylinderMat)));
0218   pv = layer.placeVolume(cylinder, 1);
0219   LogPosition(pv);
0220 
0221   //
0222   // inner part of the cylinder
0223   //
0224   rin += supportT;
0225   rout -= supportT;
0226   name = idName + "CylinderIn";
0227   solid = ns.addSolidNS(ns.prepend(name), Tube(rin, rout, 0.5 * layerL));
0228   edm::LogVerbatim("TIBGeom") << solid.name() << " Tubs made of " << genMat << " from 0 to " << convertRadToDeg(2_pi)
0229                               << " with Rin " << rin << " Rout " << rout << " ZHalf " << 0.5 * layerL;
0230   Volume cylinderIn = ns.addVolumeNS(Volume(ns.prepend(name), solid, ns.material(genMat)));
0231   pv = cylinder.placeVolume(cylinderIn, 1);
0232   LogPosition(pv);
0233 
0234   //
0235   // Filler Rings
0236   //
0237   name = idName + "Filler";
0238   solid = ns.addSolidNS(ns.prepend(name), Tube(rin, rout, fillerDz));
0239   edm::LogVerbatim("TIBGeom") << solid.name() << " Tubs made of " << fillerMat << " from " << 0. << " to "
0240                               << convertRadToDeg(2_pi) << " with Rin " << rin << " Rout " << rout << " ZHalf "
0241                               << fillerDz;
0242   Volume cylinderFiller = ns.addVolumeNS(Volume(ns.prepend(name), solid, ns.material(fillerMat)));
0243   pv = cylinderIn.placeVolume(cylinderFiller, 1, Position(0.0, 0.0, 0.5 * layerL - fillerDz));
0244   LogPosition(pv);
0245 
0246   pv = cylinderIn.placeVolume(cylinderFiller, 2, Position(0.0, 0.0, -0.5 * layerL + fillerDz));
0247   LogPosition(pv);
0248 
0249   //
0250   // Ribs
0251   //
0252   Material matrib = ns.material(ribMat);
0253   for (size_t i = 0; i < ribW.size(); i++) {
0254     name = idName + "Rib" + std::to_string(i);
0255     double width = 2. * ribW[i] / (rin + rout);
0256     double dz = 0.5 * layerL - 2. * fillerDz;
0257     double _rmi = std::min(rin + 0.5 * dd4hep::mm, rout - 0.5 * dd4hep::mm);
0258     double _rma = std::max(rin + 0.5 * dd4hep::mm, rout - 0.5 * dd4hep::mm);
0259     solid = ns.addSolidNS(ns.prepend(name), Tube(_rmi, _rma, dz, -0.5 * width, 0.5 * width));
0260     edm::LogVerbatim("TIBGeom") << solid.name() << " Tubs made of " << ribMat << " from "
0261                                 << -0.5 * convertRadToDeg(width) << " to " << 0.5 * convertRadToDeg(width)
0262                                 << " with Rin " << rin + 0.5 * dd4hep::mm << " Rout " << rout - 0.5 * dd4hep::mm
0263                                 << " ZHalf " << dz;
0264     Volume cylinderRib = ns.addVolumeNS(Volume(ns.prepend(name), solid, matrib));
0265     double phix = ribPhi[i];
0266     double theta = 90_deg;
0267     double phiy = phix + 90._deg;
0268     Rotation3D rotation = makeRotation3D(theta, phix, theta, phiy, 0., 0.);
0269     Position tran(0, 0, 0);
0270     pv = cylinderIn.placeVolume(cylinderRib, 1, Transform3D(rotation, tran));
0271     LogPosition(pv);
0272   }
0273 
0274   //
0275   //Manifold rings
0276   //
0277   // Inner ones first
0278   rin = MFRingInR;
0279   rout = rin + MFRingT;
0280   name = idName + "InnerMFRing";
0281   solid = ns.addSolidNS(ns.prepend(name), Tube(rin, rout, MFRingDz));
0282   edm::LogVerbatim("TIBGeom") << solid.name() << " Tubs made of " << MFIntRingMat << " from 0 to "
0283                               << convertRadToDeg(2_pi) << " with Rin " << rin << " Rout " << rout << " ZHalf "
0284                               << MFRingDz;
0285 
0286   Volume inmfr = ns.addVolumeNS(Volume(ns.prepend(name), solid, ns.material(MFIntRingMat)));
0287 
0288   pv = layer.placeVolume(inmfr, 1, Position(0.0, 0.0, -0.5 * layerL + MFRingDz));
0289   LogPosition(pv);
0290 
0291   pv = layer.placeVolume(inmfr, 2, Position(0.0, 0.0, +0.5 * layerL - MFRingDz));
0292   LogPosition(pv);
0293 
0294   // Outer ones
0295   rout = MFRingOutR;
0296   rin = rout - MFRingT;
0297   name = idName + "OuterMFRing";
0298   solid = ns.addSolidNS(ns.prepend(name), Tube(rin, rout, MFRingDz));
0299   edm::LogVerbatim("TIBGeom") << solid.name() << " Tubs made of " << MFExtRingMat << " from 0 to "
0300                               << convertRadToDeg(2_pi) << " with Rin " << rin << " Rout " << rout << " ZHalf "
0301                               << MFRingDz;
0302 
0303   Volume outmfr = ns.addVolumeNS(Volume(ns.prepend(name), solid, ns.material(MFExtRingMat)));
0304   pv = layer.placeVolume(outmfr, 1, Position(0.0, 0.0, -0.5 * layerL + MFRingDz));
0305   LogPosition(pv);
0306   pv = layer.placeVolume(outmfr, 2, Position(0.0, 0.0, +0.5 * layerL - MFRingDz));
0307   LogPosition(pv);
0308 
0309   //
0310   //Central Support rings
0311   //
0312   // Ring 1
0313   double centZ = centRing1par[0];
0314   double centDz = 0.5 * centRing1par[1];
0315   rin = centRing1par[2];
0316   rout = centRing1par[3];
0317   name = idName + "CentRing1";
0318   solid = ns.addSolidNS(ns.prepend(name), Tube(rin, rout, centDz));
0319 
0320   edm::LogVerbatim("TIBGeom") << solid.name() << " Tubs made of " << centMat << " from 0 to " << convertRadToDeg(2_pi)
0321                               << " with Rin " << rin << " Rout " << rout << " ZHalf " << centDz;
0322 
0323   Volume cent1 = ns.addVolumeNS(Volume(ns.prepend(name), solid, ns.material(centMat)));
0324   pv = layer.placeVolume(cent1, 1, Position(0.0, 0.0, centZ));
0325   LogPosition(pv);
0326   // Ring 2
0327   centZ = centRing2par[0];
0328   centDz = 0.5 * centRing2par[1];
0329   rin = centRing2par[2];
0330   rout = centRing2par[3];
0331   name = idName + "CentRing2";
0332   solid = ns.addSolidNS(ns.prepend(name), Tube(rin, rout, centDz));
0333   edm::LogVerbatim("TIBGeom") << solid.name() << " Tubs made of " << centMat << " from 0 to " << convertRadToDeg(2_pi)
0334                               << " with Rin " << rin << " Rout " << rout << " ZHalf " << centDz;
0335 
0336   Volume cent2 = ns.addVolumeNS(Volume(ns.prepend(name), solid, ns.material(centMat)));
0337   pv = layer.placeVolume(cent2, 1, Position(0e0, 0e0, centZ));
0338   LogPosition(pv);
0339 
0340   //
0341   ////// DOHM
0342   //
0343   // Preparing DOHM Carrier solid
0344   //
0345   name = idName + "DOHMCarrier";
0346   double dohmCarrierRin = MFRingOutR - MFRingT;
0347   double dohmCarrierRout = MFRingOutR;
0348   double dohmCarrierDz = 0.5 * (dohmPrimL + dohmtoMF);
0349   double dohmCarrierZ = 0.5 * layerL - 2. * MFRingDz - dohmCarrierDz;
0350 
0351   solid = ns.addSolidNS(
0352       ns.prepend(name),
0353       Tube(dohmCarrierRin, dohmCarrierRout, dohmCarrierDz, dohmCarrierPhiOff, 180._deg - dohmCarrierPhiOff));
0354   edm::LogVerbatim("TIBGeom") << solid.name() << " Tubs made of " << dohmCarrierMaterial << " from "
0355                               << dohmCarrierPhiOff << " to " << 180._deg - dohmCarrierPhiOff << " with Rin "
0356                               << dohmCarrierRin << " Rout " << MFRingOutR << " ZHalf " << dohmCarrierDz;
0357 
0358   // Define FW and BW carrier logical volume and
0359   // place DOHM Primary and auxiliary modules inside it
0360   dphi = 2_pi / stringsUp;
0361 
0362   Rotation3D dohmRotation;
0363   double dohmR = 0.5 * (dohmCarrierRin + dohmCarrierRout);
0364 
0365   for (int j = 0; j < 4; j++) {
0366     vector<double> dohmList;
0367     Position tran;
0368     string rotstr;
0369     Rotation3D rotation;
0370     int dohmCarrierReplica = 0;
0371     int placeDohm = 0;
0372 
0373     Volume dohmCarrier;
0374 
0375     switch (j) {
0376       case 0:
0377         name = idName + "DOHMCarrierFW";
0378         dohmCarrier = ns.addVolumeNS(Volume(ns.prepend(name), solid, ns.material(dohmCarrierMaterial)));
0379         dohmList = dohmListFW;
0380         tran = Position(0., 0., dohmCarrierZ);
0381         rotstr = idName + "FwUp";
0382         rotation = Rotation3D();
0383         dohmCarrierReplica = 1;
0384         placeDohm = 1;
0385         break;
0386       case 1:
0387         name = idName + "DOHMCarrierFW";
0388         dohmCarrier = ns.volume(name);  // Re-use internally stored DOHMCarrierFW Volume
0389         dohmList = dohmListFW;
0390         tran = Position(0., 0., dohmCarrierZ);
0391         rotstr = idName + "FwDown";
0392         rotation = makeRotation3D(90._deg, 180._deg, 90._deg, 270._deg, 0., 0.);
0393         dohmCarrierReplica = 2;
0394         placeDohm = 0;
0395         break;
0396       case 2:
0397         name = idName + "DOHMCarrierBW";
0398         dohmCarrier = ns.addVolumeNS(Volume(ns.prepend(name), solid, ns.material(dohmCarrierMaterial)));
0399         dohmList = dohmListBW;
0400         tran = Position(0., 0., -dohmCarrierZ);
0401         rotstr = idName + "BwUp";
0402         rotation = makeRotation3D(90._deg, 180._deg, 90._deg, 90._deg, 180._deg, 0.);
0403         dohmCarrierReplica = 1;
0404         placeDohm = 1;
0405         break;
0406       case 3:
0407         name = idName + "DOHMCarrierBW";
0408         dohmCarrier = ns.volume(name);  // Re-use internally stored DOHMCarrierBW Volume
0409         dohmList = dohmListBW;
0410         tran = Position(0., 0., -dohmCarrierZ);
0411         rotstr = idName + "BwDown";
0412         rotation = makeRotation3D(90._deg, 0., 90._deg, 270._deg, 180._deg, 0.);
0413         dohmCarrierReplica = 2;
0414         placeDohm = 0;
0415         break;
0416     }
0417 
0418     int primReplica = 0;
0419     int auxReplica = 0;
0420 
0421     for (size_t i = 0; i < placeDohm * dohmList.size(); i++) {
0422       double phi = (std::abs(dohmList[i]) + 0.5 - 1.) * dphi;
0423       double phix = phi + 90_deg;
0424       double phideg = convertRadToDeg(phix);
0425       if (phideg != 0) {
0426         double theta = 90_deg;
0427         double phiy = phix + 90._deg;
0428         dohmRotation = makeRotation3D(theta, phix, theta, phiy, 0., 0.);
0429       }
0430       int dohmReplica = 0;
0431       double dohmZ = 0.;
0432       Volume dohm;
0433 
0434       if (dohmList[i] < 0.) {
0435         // Place a Auxiliary DOHM
0436         dohm = ns.volume(dohmAuxName);
0437         dohmZ = dohmCarrierDz - 0.5 * dohmAuxL - dohmtoMF;
0438         primReplica++;
0439         dohmReplica = primReplica;
0440       } else {
0441         // Place a Primary DOHM
0442         dohm = ns.volume(dohmPrimName);
0443         dohmZ = dohmCarrierDz - 0.5 * dohmPrimL - dohmtoMF;
0444         auxReplica++;
0445         dohmReplica = auxReplica;
0446       }
0447       Position dohmTrasl(dohmR * cos(phi), dohmR * sin(phi), dohmZ);
0448       pv = dohmCarrier.placeVolume(dohm, dohmReplica, Transform3D(dohmRotation, dohmTrasl));
0449       LogPosition(pv);
0450     }
0451 
0452     pv = layer.placeVolume(dohmCarrier, dohmCarrierReplica, Transform3D(rotation, tran));
0453     LogPosition(pv);
0454   }
0455   //
0456   ////// PILLARS
0457   for (int j = 0; j < 4; j++) {
0458     vector<double> pillarZ;
0459     vector<double> pillarPhi;
0460     double pillarDz = 0, pillarDPhi = 0, pillarRin = 0, pillarRout = 0;
0461 
0462     switch (j) {
0463       case 0:
0464         name = idName + "FWIntPillar";
0465         pillarZ = fwIntPillarZ;
0466         pillarPhi = fwIntPillarPhi;
0467         pillarRin = MFRingInR;
0468         pillarRout = MFRingInR + MFRingT;
0469         pillarDz = fwIntPillarDz;
0470         pillarDPhi = fwIntPillarDPhi;
0471         break;
0472       case 1:
0473         name = idName + "BWIntPillar";
0474         pillarZ = bwIntPillarZ;
0475         pillarPhi = bwIntPillarPhi;
0476         pillarRin = MFRingInR;
0477         pillarRout = MFRingInR + MFRingT;
0478         pillarDz = bwIntPillarDz;
0479         pillarDPhi = bwIntPillarDPhi;
0480         break;
0481       case 2:
0482         name = idName + "FWExtPillar";
0483         pillarZ = fwExtPillarZ;
0484         pillarPhi = fwExtPillarPhi;
0485         pillarRin = MFRingOutR - MFRingT;
0486         pillarRout = MFRingOutR;
0487         pillarDz = fwExtPillarDz;
0488         pillarDPhi = fwExtPillarDPhi;
0489         break;
0490       case 3:
0491         name = idName + "BWExtPillar";
0492         pillarZ = bwExtPillarZ;
0493         pillarPhi = bwExtPillarPhi;
0494         pillarRin = MFRingOutR - MFRingT;
0495         pillarRout = MFRingOutR;
0496         pillarDz = bwExtPillarDz;
0497         pillarDPhi = bwExtPillarDPhi;
0498         break;
0499     }
0500 
0501     solid = ns.addSolidNS(ns.prepend(name), Tube(pillarRin, pillarRout, pillarDz, -pillarDPhi, pillarDPhi));
0502     Volume Pillar = ns.addVolumeNS(Volume(ns.prepend(name), solid, ns.material(pillarMaterial)));
0503     edm::LogVerbatim("TIBGeom") << solid.name() << " Tubs made of " << pillarMaterial << " from " << -pillarDPhi
0504                                 << " to " << pillarDPhi << " with Rin " << pillarRin << " Rout " << pillarRout
0505                                 << " ZHalf " << pillarDz;
0506     Position pillarTran;
0507     Rotation3D pillarRota;
0508     for (unsigned int i = 0; i < pillarZ.size(); i++) {
0509       if (pillarPhi[i] > 0.) {
0510         pillarTran = Position(0., 0., pillarZ[i]);
0511         pillarRota = makeRotation3D(90._deg, pillarPhi[i], 90._deg, 90._deg + pillarPhi[i], 0., 0.);
0512         pv = layer.placeVolume(Pillar, i, Transform3D(pillarRota, pillarTran));
0513         LogPosition(pv);
0514       }
0515     }
0516   }
0517   return 1;
0518 }
0519 
0520 // first argument is the type from the xml file
0521 DECLARE_DDCMS_DETELEMENT(DDCMS_track_DDTIBLayerAlgo, algorithm)