Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 12:49:03

0001 ///////////////////////////////////////////////////////////////////////////////
0002 // File: DDTIBLayerAlgo.cc
0003 // Description: Makes a TIB layer and position the strings with a tilt angle
0004 ///////////////////////////////////////////////////////////////////////////////
0005 
0006 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0007 #include "DetectorDescription/Core/interface/DDLogicalPart.h"
0008 #include "DetectorDescription/Core/interface/DDSolid.h"
0009 #include "DetectorDescription/Core/interface/DDMaterial.h"
0010 #include "DetectorDescription/Core/interface/DDCurrentNamespace.h"
0011 #include "DetectorDescription/Core/interface/DDSplit.h"
0012 #include "DetectorDescription/Core/interface/DDTypes.h"
0013 #include "DetectorDescription/Core/interface/DDAlgorithm.h"
0014 #include "DetectorDescription/Core/interface/DDAlgorithmFactory.h"
0015 #include "CLHEP/Units/GlobalPhysicalConstants.h"
0016 #include "CLHEP/Units/GlobalSystemOfUnits.h"
0017 
0018 #include <cmath>
0019 #include <algorithm>
0020 #include <map>
0021 #include <string>
0022 #include <vector>
0023 
0024 using namespace std;
0025 
0026 class DDTIBLayerAlgo : public DDAlgorithm {
0027 public:
0028   //Constructor and Destructor
0029   DDTIBLayerAlgo();
0030   ~DDTIBLayerAlgo() override;
0031 
0032   void initialize(const DDNumericArguments& nArgs,
0033                   const DDVectorArguments& vArgs,
0034                   const DDMapArguments& mArgs,
0035                   const DDStringArguments& sArgs,
0036                   const DDStringVectorArguments& vsArgs) override;
0037 
0038   void execute(DDCompactView& cpv) override;
0039 
0040 private:
0041   string idNameSpace;   //Namespace of this and ALL parts
0042   string genMat;        //General material name
0043   double detectorTilt;  //Detector Tilt
0044   double layerL;        //Length of the layer
0045 
0046   double radiusLo;    //Radius for detector at lower level
0047   double phioffLo;    //Phi offset             ......
0048   int stringsLo;      //Number of strings      ......
0049   string detectorLo;  //Detector string name   ......
0050 
0051   double radiusUp;    //Radius for detector at upper level
0052   double phioffUp;    //Phi offset             ......
0053   int stringsUp;      //Number of strings      ......
0054   string detectorUp;  //Detector string name   ......
0055 
0056   double cylinderT;     //Cylinder thickness
0057   double cylinderInR;   //Cylinder inner radius
0058   string cylinderMat;   //Cylinder material
0059   double MFRingInR;     //Inner Manifold Ring Inner Radius
0060   double MFRingOutR;    //Outer Manifold Ring Outer Radius
0061   double MFRingT;       //Manifold Ring Thickness
0062   double MFRingDz;      //Manifold Ring Half Lenght
0063   string MFIntRingMat;  //Manifold Ring Material
0064   string MFExtRingMat;  //Manifold Ring Material
0065 
0066   double supportT;  //Cylinder barrel CF skin thickness
0067 
0068   string centMat;               //Central rings  material
0069   vector<double> centRing1par;  //Central rings parameters
0070   vector<double> centRing2par;  //Central rings parameters
0071 
0072   string fillerMat;  //Filler material
0073   double fillerDz;   //Filler Half Length
0074 
0075   string ribMat;          //Rib material
0076   vector<double> ribW;    //Rib width
0077   vector<double> ribPhi;  //Rib Phi position
0078 
0079   vector<double> dohmListFW;  //DOHM/AUX positions in #strings FW
0080   vector<double> dohmListBW;  //DOHM/AUX positions in #strings BW
0081 
0082   double dohmtoMF;           //DOHM Distance to MF
0083   double dohmCarrierPhiOff;  //DOHM Carrier Phi offset wrt horizontal
0084   string dohmPrimName;       //DOHM Primary Logical Volume name
0085   string dohmAuxName;        //DOHM Auxiliary Logical Volume name
0086 
0087   string dohmCarrierMaterial;  //DOHM Carrier Material
0088   string dohmCableMaterial;    //DOHM Cable Material
0089   double dohmPrimL;            //DOHM PRIMary Length
0090   string dohmPrimMaterial;     //DOHM PRIMary Material
0091   double dohmAuxL;             //DOHM AUXiliary Length
0092   string dohmAuxMaterial;      //DOHM AUXiliary Material
0093 
0094   string pillarMaterial;  //Pillar Material
0095 
0096   double fwIntPillarDz;  //Internal pillar parameters
0097   double fwIntPillarDPhi;
0098   vector<double> fwIntPillarZ;
0099   vector<double> fwIntPillarPhi;
0100   double bwIntPillarDz;
0101   double bwIntPillarDPhi;
0102   vector<double> bwIntPillarZ;
0103   vector<double> bwIntPillarPhi;
0104 
0105   double fwExtPillarDz;  //External pillar parameters
0106   double fwExtPillarDPhi;
0107   vector<double> fwExtPillarZ;
0108   vector<double> fwExtPillarPhi;
0109   double bwExtPillarDz;
0110   double bwExtPillarDPhi;
0111   vector<double> bwExtPillarZ;
0112   vector<double> bwExtPillarPhi;
0113 };
0114 
0115 DDTIBLayerAlgo::DDTIBLayerAlgo() : ribW(0), ribPhi(0) {
0116   LogDebug("TIBGeom") << "DDTIBLayerAlgo info: Creating an instance";
0117 }
0118 
0119 DDTIBLayerAlgo::~DDTIBLayerAlgo() {}
0120 
0121 void DDTIBLayerAlgo::initialize(const DDNumericArguments& nArgs,
0122                                 const DDVectorArguments& vArgs,
0123                                 const DDMapArguments&,
0124                                 const DDStringArguments& sArgs,
0125                                 const DDStringVectorArguments&) {
0126   idNameSpace = DDCurrentNamespace::ns();
0127   genMat = sArgs["GeneralMaterial"];
0128   DDName parentName = parent().name();
0129   LogDebug("TIBGeom") << "DDTIBLayerAlgo debug: Parent " << parentName << " NameSpace " << idNameSpace
0130                       << " General Material " << genMat;
0131 
0132   detectorTilt = nArgs["DetectorTilt"];
0133   layerL = nArgs["LayerL"];
0134 
0135   radiusLo = nArgs["RadiusLo"];
0136   stringsLo = int(nArgs["StringsLo"]);
0137   detectorLo = sArgs["StringDetLoName"];
0138   LogDebug("TIBGeom") << "DDTIBLayerAlgo debug: Lower layer Radius " << radiusLo << " Number " << stringsLo
0139                       << " String " << detectorLo;
0140 
0141   radiusUp = nArgs["RadiusUp"];
0142   stringsUp = int(nArgs["StringsUp"]);
0143   detectorUp = sArgs["StringDetUpName"];
0144   LogDebug("TIBGeom") << "DDTIBLayerAlgo debug: Upper layer Radius " << radiusUp << " Number " << stringsUp
0145                       << " String " << detectorUp;
0146 
0147   cylinderT = nArgs["CylinderThickness"];
0148   cylinderInR = nArgs["CylinderInnerRadius"];
0149   cylinderMat = sArgs["CylinderMaterial"];
0150   MFRingInR = nArgs["MFRingInnerRadius"];
0151   MFRingOutR = nArgs["MFRingOuterRadius"];
0152   MFRingT = nArgs["MFRingThickness"];
0153   MFRingDz = nArgs["MFRingDeltaz"];
0154   MFIntRingMat = sArgs["MFIntRingMaterial"];
0155   MFExtRingMat = sArgs["MFExtRingMaterial"];
0156 
0157   supportT = nArgs["SupportThickness"];
0158 
0159   centMat = sArgs["CentRingMaterial"];
0160   centRing1par = vArgs["CentRing1"];
0161   centRing2par = vArgs["CentRing2"];
0162 
0163   fillerMat = sArgs["FillerMaterial"];
0164   fillerDz = nArgs["FillerDeltaz"];
0165 
0166   ribMat = sArgs["RibMaterial"];
0167   ribW = vArgs["RibWidth"];
0168   ribPhi = vArgs["RibPhi"];
0169   LogDebug("TIBGeom") << "DDTIBLayerAlgo debug: Cylinder Material/"
0170                       << "thickness " << cylinderMat << " " << cylinderT << " Rib Material " << ribMat << " at "
0171                       << ribW.size() << " positions with width/phi";
0172 
0173   for (unsigned int i = 0; i < ribW.size(); i++)
0174     LogDebug("TIBGeom") << "\tribW[" << i << "] = " << ribW[i] << "\tribPhi[" << i << "] = " << ribPhi[i] / CLHEP::deg;
0175 
0176   dohmCarrierPhiOff = nArgs["DOHMCarrierPhiOffset"];
0177 
0178   dohmtoMF = nArgs["DOHMtoMFDist"];
0179 
0180   dohmPrimName = sArgs["StringDOHMPrimName"];
0181   dohmAuxName = sArgs["StringDOHMAuxName"];
0182 
0183   dohmCarrierMaterial = sArgs["DOHMCarrierMaterial"];
0184   dohmCableMaterial = sArgs["DOHMCableMaterial"];
0185   dohmPrimL = nArgs["DOHMPRIMLength"];
0186   dohmPrimMaterial = sArgs["DOHMPRIMMaterial"];
0187   dohmAuxL = nArgs["DOHMAUXLength"];
0188   dohmAuxMaterial = sArgs["DOHMAUXMaterial"];
0189   dohmListFW = vArgs["DOHMListFW"];
0190   dohmListBW = vArgs["DOHMListBW"];
0191   LogDebug("TIBGeom") << "DDTIBLayerAlgo debug: DOHM Primary "
0192                       << " Material " << dohmPrimMaterial << " Length " << dohmPrimL;
0193   LogDebug("TIBGeom") << "DDTIBLayerAlgo debug: DOHM Aux     "
0194                       << " Material " << dohmAuxMaterial << " Length " << dohmAuxL;
0195   for (double i : dohmListFW) {
0196     if (i > 0.)
0197       LogDebug("TIBGeom") << "DOHM Primary at FW Position " << i;
0198     if (i < 0.)
0199       LogDebug("TIBGeom") << "DOHM Aux     at FW Position " << -i;
0200   }
0201   for (double i : dohmListBW) {
0202     if (i > 0.)
0203       LogDebug("TIBGeom") << "DOHM Primary at BW Position " << i;
0204     if (i < 0.)
0205       LogDebug("TIBGeom") << "DOHM Aux     at BW Position " << -i;
0206   }
0207 
0208   //Pillar Material
0209   pillarMaterial = sArgs["PillarMaterial"];
0210 
0211   // Internal Pillar Parameters
0212   fwIntPillarDz = nArgs["FWIntPillarDz"];
0213   fwIntPillarDPhi = nArgs["FWIntPillarDPhi"];
0214   fwIntPillarZ = vArgs["FWIntPillarZ"];
0215   fwIntPillarPhi = vArgs["FWIntPillarPhi"];
0216   bwIntPillarDz = nArgs["BWIntPillarDz"];
0217   bwIntPillarDPhi = nArgs["BWIntPillarDPhi"];
0218   bwIntPillarZ = vArgs["BWIntPillarZ"];
0219   bwIntPillarPhi = vArgs["BWIntPillarPhi"];
0220   LogDebug("TIBGeom") << "FW Internal Pillar [Dz, DPhi] " << fwIntPillarDz << ", " << fwIntPillarDPhi;
0221   for (unsigned int i = 0; i < fwIntPillarZ.size(); i++) {
0222     if (fwIntPillarPhi[i] > 0.) {
0223       LogDebug("TIBGeom") << " at positions [z, phi] " << fwIntPillarZ[i] << " " << fwIntPillarPhi[i];
0224     }
0225   }
0226   LogDebug("TIBGeom") << "BW Internal Pillar [Dz, DPhi] " << bwIntPillarDz << ", " << bwIntPillarDPhi;
0227   for (unsigned int i = 0; i < bwIntPillarZ.size(); i++) {
0228     if (bwIntPillarPhi[i] > 0.) {
0229       LogDebug("TIBGeom") << " at positions [z, phi] " << bwIntPillarZ[i] << " " << bwIntPillarPhi[i];
0230     }
0231   }
0232 
0233   // External Pillar Parameters
0234   fwExtPillarDz = nArgs["FWExtPillarDz"];
0235   fwExtPillarDPhi = nArgs["FWExtPillarDPhi"];
0236   fwExtPillarZ = vArgs["FWExtPillarZ"];
0237   fwExtPillarPhi = vArgs["FWExtPillarPhi"];
0238   bwExtPillarDz = nArgs["BWExtPillarDz"];
0239   bwExtPillarDPhi = nArgs["BWExtPillarDPhi"];
0240   bwExtPillarZ = vArgs["BWExtPillarZ"];
0241   bwExtPillarPhi = vArgs["BWExtPillarPhi"];
0242   LogDebug("TIBGeom") << "FW External Pillar [Dz, DPhi] " << fwExtPillarDz << ", " << fwExtPillarDPhi;
0243   for (unsigned int i = 0; i < fwExtPillarZ.size(); i++) {
0244     if (fwExtPillarPhi[i] > 0.) {
0245       LogDebug("TIBGeom") << " at positions [z, phi] " << fwExtPillarZ[i] << " " << fwExtPillarPhi[i];
0246     }
0247   }
0248   LogDebug("TIBGeom") << "BW External Pillar [Dz, DPhi] " << bwExtPillarDz << ", " << bwExtPillarDPhi;
0249   for (unsigned int i = 0; i < bwExtPillarZ.size(); i++) {
0250     if (bwExtPillarPhi[i] > 0.) {
0251       LogDebug("TIBGeom") << " at positions [z, phi] " << bwExtPillarZ[i] << " " << bwExtPillarPhi[i];
0252     }
0253   }
0254 }
0255 
0256 void DDTIBLayerAlgo::execute(DDCompactView& cpv) {
0257   LogDebug("TIBGeom") << "==>> Constructing DDTIBLayerAlgo...";
0258 
0259   DDName parentName = parent().name();
0260   const string& idName = parentName.name();
0261 
0262   double rmin = MFRingInR;
0263   double rmax = MFRingOutR;
0264 
0265   DDSolid solid = DDSolidFactory::tubs(DDName(idName, idNameSpace), 0.5 * layerL, rmin, rmax, 0, CLHEP::twopi);
0266 
0267   LogDebug("TIBGeom") << "DDTIBLayerAlgo test: " << DDName(idName, idNameSpace) << " Tubs made of " << genMat
0268                       << " from 0 to " << CLHEP::twopi / CLHEP::deg << " with Rin " << rmin << " Rout " << rmax
0269                       << " ZHalf " << 0.5 * layerL;
0270 
0271   DDName matname(DDSplit(genMat).first, DDSplit(genMat).second);
0272   DDMaterial matter(matname);
0273   DDLogicalPart layer(solid.ddname(), matter, solid);
0274 
0275   //Internal layer first
0276   double rin = rmin + MFRingT;
0277   //  double rout = 0.5*(radiusLo+radiusUp-cylinderT);
0278   double rout = cylinderInR;
0279   string name = idName + "Down";
0280   solid = DDSolidFactory::tubs(DDName(name, idNameSpace), 0.5 * layerL, rin, rout, 0, CLHEP::twopi);
0281   LogDebug("TIBGeom") << "DDTIBLayerAlgo test: " << DDName(name, idNameSpace) << " Tubs made of " << genMat
0282                       << " from 0 to " << CLHEP::twopi / CLHEP::deg << " with Rin " << rin << " Rout " << rout
0283                       << " ZHalf " << 0.5 * layerL;
0284   DDLogicalPart layerIn(solid.ddname(), matter, solid);
0285   cpv.position(layerIn, layer, 1, DDTranslation(0.0, 0.0, 0.0), DDRotation());
0286   LogDebug("TIBGeom") << "DDTIBLayerAlgo test: " << layerIn.name() << " number 1 positioned in " << layer.name()
0287                       << " at (0,0,0) with no rotation";
0288 
0289   double rposdet = radiusLo;
0290   double dphi = CLHEP::twopi / stringsLo;
0291   DDName detIn(DDSplit(detectorLo).first, DDSplit(detectorLo).second);
0292   for (int n = 0; n < stringsLo; n++) {
0293     double phi = (n + 0.5) * dphi;
0294     double phix = phi - detectorTilt + 90 * CLHEP::deg;
0295     double phideg = phix / CLHEP::deg;
0296     DDRotation rotation;
0297     if (phideg != 0) {
0298       double theta = 90 * CLHEP::deg;
0299       double phiy = phix + 90. * CLHEP::deg;
0300       string rotstr = idName + to_string(phideg * 10.);
0301       rotation = DDRotation(DDName(rotstr, idNameSpace));
0302       if (!rotation) {
0303         LogDebug("TIBGeom") << "DDTIBLayerAlgo test: Creating a new "
0304                             << "rotation: " << rotstr << "\t90., " << phix / CLHEP::deg << ", 90.," << phiy / CLHEP::deg
0305                             << ", 0, 0";
0306         rotation = DDrot(DDName(rotstr, idNameSpace), theta, phix, theta, phiy, 0., 0.);
0307       }
0308     }
0309     DDTranslation trdet(rposdet * cos(phi), rposdet * sin(phi), 0);
0310     cpv.position(detIn, layerIn, n + 1, trdet, rotation);
0311     LogDebug("TIBGeom") << "DDTIBLayerAlgo test " << detIn.name() << " number " << n + 1 << " positioned in "
0312                         << layerIn.name() << " at " << trdet << " with " << rotation;
0313   }
0314 
0315   //Now the external layer
0316   rin = cylinderInR + cylinderT;
0317   rout = rmax - MFRingT;
0318   name = idName + "Up";
0319   solid = DDSolidFactory::tubs(DDName(name, idNameSpace), 0.5 * layerL, rin, rout, 0, CLHEP::twopi);
0320   LogDebug("TIBGeom") << "DDTIBLayerAlgo test: " << DDName(name, idNameSpace) << " Tubs made of " << genMat
0321                       << " from 0 to " << CLHEP::twopi / CLHEP::deg << " with Rin " << rin << " Rout " << rout
0322                       << " ZHalf " << 0.5 * layerL;
0323   DDLogicalPart layerOut(solid.ddname(), matter, solid);
0324   cpv.position(layerOut, layer, 1, DDTranslation(0.0, 0.0, 0.0), DDRotation());
0325   LogDebug("TIBGeom") << "DDTIBLayerAlgo test: " << layerOut.name() << " number 1 positioned in " << layer.name()
0326                       << " at (0,0,0) with no rotation";
0327 
0328   rposdet = radiusUp;
0329   dphi = CLHEP::twopi / stringsUp;
0330   DDName detOut(DDSplit(detectorUp).first, DDSplit(detectorUp).second);
0331   for (int n = 0; n < stringsUp; n++) {
0332     double phi = (n + 0.5) * dphi;
0333     double phix = phi - detectorTilt - 90 * CLHEP::deg;
0334     double phideg = phix / CLHEP::deg;
0335     DDRotation rotation;
0336     if (phideg != 0) {
0337       double theta = 90 * CLHEP::deg;
0338       double phiy = phix + 90. * CLHEP::deg;
0339       string rotstr = idName + to_string(phideg * 10.);
0340       rotation = DDRotation(DDName(rotstr, idNameSpace));
0341       if (!rotation) {
0342         LogDebug("TIBGeom") << "DDTIBLayerAlgo test: Creating a new "
0343                             << "rotation: " << rotstr << "\t90., " << phix / CLHEP::deg << ", 90.," << phiy / CLHEP::deg
0344                             << ", 0, 0";
0345         rotation = DDrot(DDName(rotstr, idNameSpace), theta, phix, theta, phiy, 0., 0.);
0346       }
0347     }
0348     DDTranslation trdet(rposdet * cos(phi), rposdet * sin(phi), 0);
0349     cpv.position(detOut, layerOut, n + 1, trdet, rotation);
0350     LogDebug("TIBGeom") << "DDTIBLayerAlgo test " << detOut.name() << " number " << n + 1 << " positioned in "
0351                         << layerOut.name() << " at " << trdet << " with " << rotation;
0352   }
0353 
0354   //
0355   // Inner cylinder, support wall and ribs
0356   //
0357   // External skins
0358   rin = cylinderInR;
0359   rout = cylinderInR + cylinderT;
0360   name = idName + "Cylinder";
0361   solid = DDSolidFactory::tubs(DDName(name, idNameSpace), 0.5 * layerL, rin, rout, 0, CLHEP::twopi);
0362   LogDebug("TIBGeom") << "DDTIBLayerAlgo test: " << DDName(name, idNameSpace) << " Tubs made of " << cylinderMat
0363                       << " from 0 to " << CLHEP::twopi / CLHEP::deg << " with Rin " << rin << " Rout " << rout
0364                       << " ZHalf " << 0.5 * layerL;
0365   matname = DDName(DDSplit(cylinderMat).first, DDSplit(cylinderMat).second);
0366   DDMaterial matcyl(matname);
0367   DDLogicalPart cylinder(solid.ddname(), matcyl, solid);
0368   cpv.position(cylinder, layer, 1, DDTranslation(0.0, 0.0, 0.0), DDRotation());
0369   LogDebug("TIBGeom") << "DDTIBLayerAlgo test: " << cylinder.name() << " number 1 positioned in " << layer.name()
0370                       << " at (0,0,0) with no rotation";
0371   //
0372   // inner part of the cylinder
0373   //
0374   rin += supportT;
0375   rout -= supportT;
0376   name = idName + "CylinderIn";
0377   solid = DDSolidFactory::tubs(DDName(name, idNameSpace), 0.5 * layerL, rin, rout, 0, CLHEP::twopi);
0378   LogDebug("TIBGeom") << "DDTIBLayerAlgo test: " << DDName(name, idNameSpace) << " Tubs made of " << genMat
0379                       << " from 0 to " << CLHEP::twopi / CLHEP::deg << " with Rin " << rin << " Rout " << rout
0380                       << " ZHalf " << 0.5 * layerL;
0381   DDLogicalPart cylinderIn(solid.ddname(), matter, solid);
0382   cpv.position(cylinderIn, cylinder, 1, DDTranslation(0.0, 0.0, 0.0), DDRotation());
0383   LogDebug("TIBGeom") << "DDTIBLayerAlgo test: " << cylinderIn.name() << " number 1 positioned in " << cylinder.name()
0384                       << " at (0,0,0) with no rotation";
0385   //
0386   // Filler Rings
0387   //
0388   matname = DDName(DDSplit(fillerMat).first, DDSplit(fillerMat).second);
0389   DDMaterial matfiller(matname);
0390   name = idName + "Filler";
0391   solid = DDSolidFactory::tubs(DDName(name, idNameSpace), fillerDz, rin, rout, 0., CLHEP::twopi);
0392   LogDebug("TIBGeom") << "DDTIBLayerAlgo test: " << DDName(name, idNameSpace) << " Tubs made of " << fillerMat
0393                       << " from " << 0. << " to " << CLHEP::twopi / CLHEP::deg << " with Rin " << rin << " Rout "
0394                       << rout << " ZHalf " << fillerDz;
0395   DDLogicalPart cylinderFiller(solid.ddname(), matfiller, solid);
0396   cpv.position(cylinderFiller, cylinderIn, 1, DDTranslation(0.0, 0.0, 0.5 * layerL - fillerDz), DDRotation());
0397   cpv.position(cylinderFiller, cylinderIn, 2, DDTranslation(0.0, 0.0, -0.5 * layerL + fillerDz), DDRotation());
0398   LogDebug("TIBGeom") << "DDTIBLayerAlgo test " << cylinderFiller.name() << " number 1"
0399                       << " positioned in " << cylinderIn.name() << " at "
0400                       << DDTranslation(0.0, 0.0, 0.5 * layerL - fillerDz) << " number 2"
0401                       << " positioned in " << cylinderIn.name() << " at "
0402                       << DDTranslation(0.0, 0.0, -0.5 * layerL + fillerDz);
0403 
0404   //
0405   // Ribs
0406   //
0407   matname = DDName(DDSplit(ribMat).first, DDSplit(ribMat).second);
0408   DDMaterial matrib(matname);
0409   for (int i = 0; i < (int)(ribW.size()); i++) {
0410     name = idName + "Rib" + to_string(i);
0411     double width = 2. * ribW[i] / (rin + rout);
0412     double dz = 0.5 * layerL - 2. * fillerDz;
0413     solid = DDSolidFactory::tubs(
0414         DDName(name, idNameSpace), dz, rin + 0.5 * CLHEP::mm, rout - 0.5 * CLHEP::mm, -0.5 * width, width);
0415     LogDebug("TIBGeom") << "DDTIBLayerAlgo test: " << DDName(name, idNameSpace) << " Tubs made of " << ribMat
0416                         << " from " << -0.5 * width / CLHEP::deg << " to " << 0.5 * width / CLHEP::deg << " with Rin "
0417                         << rin + 0.5 * CLHEP::mm << " Rout " << rout - 0.5 * CLHEP::mm << " ZHalf " << dz;
0418     DDLogicalPart cylinderRib(solid.ddname(), matrib, solid);
0419     double phix = ribPhi[i];
0420     double phideg = phix / CLHEP::deg;
0421     DDRotation rotation;
0422     if (phideg != 0) {
0423       double theta = 90 * CLHEP::deg;
0424       double phiy = phix + 90. * CLHEP::deg;
0425       string rotstr = idName + to_string(phideg * 10.);
0426       rotation = DDRotation(DDName(rotstr, idNameSpace));
0427       if (!rotation) {
0428         LogDebug("TIBGeom") << "DDTIBLayerAlgo test: Creating a new "
0429                             << "rotation: " << rotstr << "\t90., " << phix / CLHEP::deg << ", 90.," << phiy / CLHEP::deg
0430                             << ", 0, 0";
0431         rotation = DDrot(DDName(rotstr, idNameSpace), theta, phix, theta, phiy, 0., 0.);
0432       }
0433     }
0434     DDTranslation tran(0, 0, 0);
0435     cpv.position(cylinderRib, cylinderIn, 1, tran, rotation);
0436     LogDebug("TIBGeom") << "DDTIBLayerAlgo test " << cylinderRib.name() << " number 1"
0437                         << " positioned in " << cylinderIn.name() << " at " << tran << " with " << rotation;
0438   }
0439 
0440   //Manifold rings
0441   //
0442   // Inner ones first
0443   matname = DDName(DDSplit(MFIntRingMat).first, DDSplit(MFIntRingMat).second);
0444   DDMaterial matintmfr(matname);
0445   rin = MFRingInR;
0446   rout = rin + MFRingT;
0447   name = idName + "InnerMFRing";
0448   solid = DDSolidFactory::tubs(DDName(name, idNameSpace), MFRingDz, rin, rout, 0, CLHEP::twopi);
0449 
0450   LogDebug("TIBGeom") << "DDTIBLayerAlgo test: " << DDName(name, idNameSpace) << " Tubs made of " << MFIntRingMat
0451                       << " from 0 to " << CLHEP::twopi / CLHEP::deg << " with Rin " << rin << " Rout " << rout
0452                       << " ZHalf " << MFRingDz;
0453 
0454   DDLogicalPart inmfr(solid.ddname(), matintmfr, solid);
0455   cpv.position(inmfr, layer, 1, DDTranslation(0.0, 0.0, -0.5 * layerL + MFRingDz), DDRotation());
0456   cpv.position(inmfr, layer, 2, DDTranslation(0.0, 0.0, +0.5 * layerL - MFRingDz), DDRotation());
0457   LogDebug("TIBGeom") << "DDTIBLayerAlgo test: " << inmfr.name() << " number 1 and 2 positioned in " << layer.name()
0458                       << " at (0,0,+-" << 0.5 * layerL - MFRingDz << ") with no rotation";
0459   // Outer ones
0460   matname = DDName(DDSplit(MFExtRingMat).first, DDSplit(MFExtRingMat).second);
0461   DDMaterial matextmfr(matname);
0462   rout = MFRingOutR;
0463   rin = rout - MFRingT;
0464   name = idName + "OuterMFRing";
0465   solid = DDSolidFactory::tubs(DDName(name, idNameSpace), MFRingDz, rin, rout, 0, CLHEP::twopi);
0466 
0467   LogDebug("TIBGeom") << "DDTIBLayerAlgo test: " << DDName(name, idNameSpace) << " Tubs made of " << MFExtRingMat
0468                       << " from 0 to " << CLHEP::twopi / CLHEP::deg << " with Rin " << rin << " Rout " << rout
0469                       << " ZHalf " << MFRingDz;
0470 
0471   DDLogicalPart outmfr(solid.ddname(), matextmfr, solid);
0472   cpv.position(outmfr, layer, 1, DDTranslation(0.0, 0.0, -0.5 * layerL + MFRingDz), DDRotation());
0473   cpv.position(outmfr, layer, 2, DDTranslation(0.0, 0.0, +0.5 * layerL - MFRingDz), DDRotation());
0474   LogDebug("TIBGeom") << "DDTIBLayerAlgo test: " << outmfr.name() << " number 1 and 2 positioned in " << layer.name()
0475                       << " at (0,0,+-" << 0.5 * layerL - MFRingDz << ") with no rotation";
0476 
0477   //Central Support rings
0478   //
0479   matname = DDName(DDSplit(centMat).first, DDSplit(centMat).second);
0480   DDMaterial matcent(matname);
0481   // Ring 1
0482   double centZ = centRing1par[0];
0483   double centDz = 0.5 * centRing1par[1];
0484   rin = centRing1par[2];
0485   rout = centRing1par[3];
0486   name = idName + "CentRing1";
0487   solid = DDSolidFactory::tubs(DDName(name, idNameSpace), centDz, rin, rout, 0, CLHEP::twopi);
0488 
0489   LogDebug("TIBGeom") << "DDTIBLayerAlgo test: " << DDName(name, idNameSpace) << " Tubs made of " << centMat
0490                       << " from 0 to " << CLHEP::twopi / CLHEP::deg << " with Rin " << rin << " Rout " << rout
0491                       << " ZHalf " << centDz;
0492 
0493   DDLogicalPart cent1(solid.ddname(), matcent, solid);
0494   cpv.position(cent1, layer, 1, DDTranslation(0.0, 0.0, centZ), DDRotation());
0495   LogDebug("TIBGeom") << "DDTIBLayerAlgo test: " << cent1.name() << " positioned in " << layer.name() << " at (0,0,"
0496                       << centZ << ") with no rotation";
0497   // Ring 2
0498   centZ = centRing2par[0];
0499   centDz = 0.5 * centRing2par[1];
0500   rin = centRing2par[2];
0501   rout = centRing2par[3];
0502   name = idName + "CentRing2";
0503   solid = DDSolidFactory::tubs(DDName(name, idNameSpace), centDz, rin, rout, 0, CLHEP::twopi);
0504 
0505   LogDebug("TIBGeom") << "DDTIBLayerAlgo test: " << DDName(name, idNameSpace) << " Tubs made of " << centMat
0506                       << " from 0 to " << CLHEP::twopi / CLHEP::deg << " with Rin " << rin << " Rout " << rout
0507                       << " ZHalf " << centDz;
0508 
0509   DDLogicalPart cent2(solid.ddname(), matcent, solid);
0510   cpv.position(cent2, layer, 1, DDTranslation(0.0, 0.0, centZ), DDRotation());
0511   LogDebug("TIBGeom") << "DDTIBLayerAlgo test: " << cent2.name() << " positioned in " << layer.name() << " at (0,0,"
0512                       << centZ << ") with no rotation";
0513 
0514   ////// DOHM
0515   //
0516   // Preparing DOHM Carrier solid
0517 
0518   name = idName + "DOHMCarrier";
0519 
0520   double dohmCarrierRin = MFRingOutR - MFRingT;
0521   double dohmCarrierRout = MFRingOutR;
0522   double dohmCarrierDz = 0.5 * (dohmPrimL + dohmtoMF);
0523   double dohmCarrierZ = 0.5 * layerL - 2. * MFRingDz - dohmCarrierDz;
0524 
0525   solid = DDSolidFactory::tubs(DDName(name, idNameSpace),
0526                                dohmCarrierDz,
0527                                dohmCarrierRin,
0528                                dohmCarrierRout,
0529                                dohmCarrierPhiOff,
0530                                180. * CLHEP::deg - 2. * dohmCarrierPhiOff);
0531   LogDebug("TIBGeom") << "DDTIBLayerAlgo test: " << DDName(name, idNameSpace) << " Tubs made of " << dohmCarrierMaterial
0532                       << " from " << dohmCarrierPhiOff << " to " << 180. * CLHEP::deg - dohmCarrierPhiOff
0533                       << " with Rin " << dohmCarrierRin << " Rout " << MFRingOutR << " ZHalf " << dohmCarrierDz;
0534 
0535   // Define FW and BW carrier logical volume and
0536   // place DOHM Primary and auxiliary modules inside it
0537 
0538   dphi = CLHEP::twopi / stringsUp;
0539 
0540   DDRotation dohmRotation;
0541 
0542   double dohmR = 0.5 * (dohmCarrierRin + dohmCarrierRout);
0543 
0544   for (int j = 0; j < 4; j++) {
0545     vector<double> dohmList;
0546     DDTranslation tran;
0547     string rotstr;
0548     DDRotation rotation;
0549     int dohmCarrierReplica = 0;
0550     int placeDohm = 0;
0551 
0552     switch (j) {
0553       case 0:
0554         name = idName + "DOHMCarrierFW";
0555         dohmList = dohmListFW;
0556         tran = DDTranslation(0., 0., dohmCarrierZ);
0557         rotstr = idName + "FwUp";
0558         rotation = DDRotation();
0559         dohmCarrierReplica = 1;
0560         placeDohm = 1;
0561         break;
0562       case 1:
0563         name = idName + "DOHMCarrierFW";
0564         dohmList = dohmListFW;
0565         tran = DDTranslation(0., 0., dohmCarrierZ);
0566         rotstr = idName + "FwDown";
0567         rotation = DDrot(DDName(rotstr, idNameSpace),
0568                          90. * CLHEP::deg,
0569                          180. * CLHEP::deg,
0570                          90. * CLHEP::deg,
0571                          270. * CLHEP::deg,
0572                          0.,
0573                          0.);
0574         dohmCarrierReplica = 2;
0575         placeDohm = 0;
0576         break;
0577       case 2:
0578         name = idName + "DOHMCarrierBW";
0579         dohmList = dohmListBW;
0580         tran = DDTranslation(0., 0., -dohmCarrierZ);
0581         rotstr = idName + "BwUp";
0582         rotation = DDrot(DDName(rotstr, idNameSpace),
0583                          90. * CLHEP::deg,
0584                          180. * CLHEP::deg,
0585                          90. * CLHEP::deg,
0586                          90. * CLHEP::deg,
0587                          180. * CLHEP::deg,
0588                          0.);
0589         dohmCarrierReplica = 1;
0590         placeDohm = 1;
0591         break;
0592       case 3:
0593         name = idName + "DOHMCarrierBW";
0594         dohmList = dohmListBW;
0595         tran = DDTranslation(0., 0., -dohmCarrierZ);
0596         rotstr = idName + "BwDown";
0597         rotation = DDrot(DDName(rotstr, idNameSpace),
0598                          90. * CLHEP::deg,
0599                          0.,
0600                          90. * CLHEP::deg,
0601                          270. * CLHEP::deg,
0602                          180. * CLHEP::deg,
0603                          0.);
0604         dohmCarrierReplica = 2;
0605         placeDohm = 0;
0606         break;
0607     }
0608 
0609     DDLogicalPart dohmCarrier(name, DDMaterial(dohmCarrierMaterial), solid);
0610 
0611     int primReplica = 0;
0612     int auxReplica = 0;
0613 
0614     for (int i = 0; i < placeDohm * ((int)(dohmList.size())); i++) {
0615       double phi = (abs(dohmList[i]) + 0.5 - 1.) * dphi;
0616       double phix = phi + 90 * CLHEP::deg;
0617       double phideg = phix / CLHEP::deg;
0618       if (phideg != 0) {
0619         double theta = 90 * CLHEP::deg;
0620         double phiy = phix + 90. * CLHEP::deg;
0621         string rotstr = idName + to_string(abs(dohmList[i]) - 1.);
0622         dohmRotation = DDRotation(DDName(rotstr, idNameSpace));
0623         if (!dohmRotation) {
0624           LogDebug("TIBGeom") << "DDTIBLayerAlgo test: Creating a new "
0625                               << "rotation: " << rotstr << "\t" << theta << ", " << phix / CLHEP::deg << ", " << theta
0626                               << ", " << phiy / CLHEP::deg << ", 0, 0";
0627           dohmRotation = DDrot(DDName(rotstr, idNameSpace), theta, phix, theta, phiy, 0., 0.);
0628         }
0629       }
0630 
0631       string dohmName;
0632       int dohmReplica = 0;
0633       double dohmZ = 0.;
0634 
0635       if (dohmList[i] < 0.) {
0636         // Place a Auxiliary DOHM
0637         dohmName = dohmAuxName;
0638         dohmZ = dohmCarrierDz - 0.5 * dohmAuxL - dohmtoMF;
0639         primReplica++;
0640         dohmReplica = primReplica;
0641 
0642       } else {
0643         // Place a Primary DOHM
0644         dohmName = dohmPrimName;
0645         dohmZ = dohmCarrierDz - 0.5 * dohmPrimL - dohmtoMF;
0646         auxReplica++;
0647         dohmReplica = auxReplica;
0648       }
0649 
0650       DDName dohm(DDSplit(dohmName).first, DDSplit(dohmName).second);
0651       DDTranslation dohmTrasl(dohmR * cos(phi), dohmR * sin(phi), dohmZ);
0652       cpv.position(dohm, dohmCarrier, dohmReplica, dohmTrasl, dohmRotation);
0653       LogDebug("TIBGeom") << "DDTIBLayerAlgo test " << dohm.name() << " replica " << dohmReplica << " positioned in "
0654                           << dohmCarrier.name() << " at " << dohmTrasl << " with " << dohmRotation;
0655     }
0656 
0657     cpv.position(dohmCarrier, parent(), dohmCarrierReplica, tran, rotation);
0658     LogDebug("TIBGeom") << "DDTIBLayerAlgo test " << dohmCarrier.name() << " positioned in " << parent().name()
0659                         << " at " << tran << " with " << rotation;
0660   }
0661 
0662   ////// PILLARS
0663 
0664   for (int j = 0; j < 4; j++) {
0665     matname = DDName(DDSplit(pillarMaterial).first, DDSplit(pillarMaterial).second);
0666     DDMaterial pillarMat(matname);
0667     vector<double> pillarZ;
0668     vector<double> pillarPhi;
0669     double pillarDz = 0, pillarDPhi = 0, pillarRin = 0, pillarRout = 0;
0670 
0671     switch (j) {
0672       case 0:
0673         name = idName + "FWIntPillar";
0674         pillarZ = fwIntPillarZ;
0675         pillarPhi = fwIntPillarPhi;
0676         pillarRin = MFRingInR;
0677         pillarRout = MFRingInR + MFRingT;
0678         pillarDz = fwIntPillarDz;
0679         pillarDPhi = fwIntPillarDPhi;
0680         break;
0681       case 1:
0682         name = idName + "BWIntPillar";
0683         pillarZ = bwIntPillarZ;
0684         pillarPhi = bwIntPillarPhi;
0685         pillarRin = MFRingInR;
0686         pillarRout = MFRingInR + MFRingT;
0687         pillarDz = bwIntPillarDz;
0688         pillarDPhi = bwIntPillarDPhi;
0689         break;
0690       case 2:
0691         name = idName + "FWExtPillar";
0692         pillarZ = fwExtPillarZ;
0693         pillarPhi = fwExtPillarPhi;
0694         pillarRin = MFRingOutR - MFRingT;
0695         pillarRout = MFRingOutR;
0696         pillarDz = fwExtPillarDz;
0697         pillarDPhi = fwExtPillarDPhi;
0698         break;
0699       case 3:
0700         name = idName + "BWExtPillar";
0701         pillarZ = bwExtPillarZ;
0702         pillarPhi = bwExtPillarPhi;
0703         pillarRin = MFRingOutR - MFRingT;
0704         pillarRout = MFRingOutR;
0705         pillarDz = bwExtPillarDz;
0706         pillarDPhi = bwExtPillarDPhi;
0707         break;
0708     }
0709 
0710     solid =
0711         DDSolidFactory::tubs(DDName(name, idNameSpace), pillarDz, pillarRin, pillarRout, -pillarDPhi, 2. * pillarDPhi);
0712 
0713     DDLogicalPart Pillar(name, DDMaterial(pillarMat), solid);
0714 
0715     LogDebug("TIBGeom") << "DDTIBLayerAlgo test: " << DDName(name, idNameSpace) << " Tubs made of " << pillarMat
0716                         << " from " << -pillarDPhi << " to " << pillarDPhi << " with Rin " << pillarRin << " Rout "
0717                         << pillarRout << " ZHalf " << pillarDz;
0718 
0719     DDTranslation pillarTran;
0720     DDRotation pillarRota;
0721     int pillarReplica = 0;
0722     for (unsigned int i = 0; i < pillarZ.size(); i++) {
0723       if (pillarPhi[i] > 0.) {
0724         pillarTran = DDTranslation(0., 0., pillarZ[i]);
0725         pillarRota = DDanonymousRot(unique_ptr<DDRotationMatrix>(DDcreateRotationMatrix(
0726             90. * CLHEP::deg, pillarPhi[i], 90. * CLHEP::deg, 90. * CLHEP::deg + pillarPhi[i], 0., 0.)));
0727 
0728         cpv.position(Pillar, parent(), i, pillarTran, pillarRota);
0729         LogDebug("TIBGeom") << "DDTIBLayerAlgo test " << Pillar.name() << " positioned in " << parent().name() << " at "
0730                             << pillarTran << " with " << pillarRota << " copy number " << pillarReplica;
0731 
0732         pillarReplica++;
0733       }
0734     }
0735   }
0736 }
0737 
0738 DEFINE_EDM_PLUGIN(DDAlgorithmFactory, DDTIBLayerAlgo, "track:DDTIBLayerAlgo");