Back to home page

Project CMSSW displayed by LXR

 
 

    


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

0001 ///////////////////////////////////////////////////////////////////////////////
0002 // File: DDTIDModulePosAlgo.cc
0003 // Description: Position various components inside a TID Module
0004 ///////////////////////////////////////////////////////////////////////////////
0005 
0006 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0007 #include "DetectorDescription/Core/interface/DDCurrentNamespace.h"
0008 #include "DetectorDescription/Core/interface/DDSplit.h"
0009 #include "DetectorDescription/Core/interface/DDTypes.h"
0010 #include "DetectorDescription/Core/interface/DDAlgorithm.h"
0011 #include "DetectorDescription/Core/interface/DDAlgorithmFactory.h"
0012 #include "CLHEP/Units/GlobalPhysicalConstants.h"
0013 #include "CLHEP/Units/GlobalSystemOfUnits.h"
0014 
0015 #include <string>
0016 #include <vector>
0017 
0018 using namespace std;
0019 
0020 class DDTIDModulePosAlgo : public DDAlgorithm {
0021 public:
0022   //Constructor and Destructor
0023   DDTIDModulePosAlgo();
0024   ~DDTIDModulePosAlgo() override;
0025 
0026   void initialize(const DDNumericArguments& nArgs,
0027                   const DDVectorArguments& vArgs,
0028                   const DDMapArguments& mArgs,
0029                   const DDStringArguments& sArgs,
0030                   const DDStringVectorArguments& vsArgs) override;
0031   void execute(DDCompactView& cpv) override;
0032 
0033 private:
0034   int detectorN;             //Number of detectors
0035   double detTilt;            //Tilt of stereo detector
0036   double fullHeight;         //Height
0037   string boxFrameName;       //Top frame Name
0038   double boxFrameHeight;     //          height
0039   double boxFrameWidth;      //          width
0040   double dlTop;              //Width at top of wafer
0041   double dlBottom;           //Width at bottom of wafer
0042   double dlHybrid;           //Width at the hybrid end
0043   vector<double> boxFrameZ;  //              z-positions
0044   double bottomFrameHeight;  //Bottom of the frame
0045   double bottomFrameOver;    //              overlap
0046   double topFrameHeight;     //Top    of the frame
0047   double topFrameOver;       //              overlap
0048 
0049   vector<string> sideFrameName;  //Side Frame    name
0050   vector<double> sideFrameZ;     //              z-positions
0051   vector<string>
0052       sideFrameRot;       //              rotation matrix (required for correct positiong of the hole in the StereoR)
0053   double sideFrameWidth;  //              width
0054   double sideFrameOver;   //              overlap (wrt wafer)
0055 
0056   vector<string> kaptonName;  //Kapton Circuit    name
0057   vector<double> kaptonZ;     //              z-positions
0058   vector<string> kaptonRot;  //              rotation matrix (required for correct positiong of the hole in the StereoR)
0059   vector<string> waferName;  //Wafer         name
0060   vector<double> waferZ;     //              z-positions
0061   vector<string> waferRot;   //              rotation matrix
0062   string hybridName;         //Hybrid        name
0063   double hybridHeight;       //              height
0064   vector<double> hybridZ;    //              z-positions
0065   vector<string> pitchName;  //Pitch adapter rotation matrix
0066   double pitchHeight;        //              height
0067   vector<double> pitchZ;     //              z-positions
0068   vector<string> pitchRot;   //              rotation matrix
0069   string coolName;           //Cool Insert   name
0070   double coolHeight;         //              height
0071   double coolZ;              //              z-position
0072   double coolWidth;          //              width
0073   vector<double> coolRadShift;  //
0074 
0075   bool doSpacers;           //Spacers (alumina) to be made (Should be "Yes" for DS modules only)
0076   string botSpacersName;    // Spacers at the "bottom" of the module
0077   double botSpacersHeight;  //
0078   double botSpacersZ;       //              z-position
0079   string sidSpacersName;    //Spacers at the "sides" of the module
0080   double sidSpacersHeight;
0081   double sidSpacersZ;         //              z-position
0082   double sidSpacersWidth;     //              width
0083   double sidSpacersRadShift;  //
0084 };
0085 
0086 DDTIDModulePosAlgo::DDTIDModulePosAlgo() { LogDebug("TIDGeom") << "DDTIDModulePosAlgo info: Creating an instance"; }
0087 
0088 DDTIDModulePosAlgo::~DDTIDModulePosAlgo() {}
0089 
0090 void DDTIDModulePosAlgo::initialize(const DDNumericArguments& nArgs,
0091                                     const DDVectorArguments& vArgs,
0092                                     const DDMapArguments&,
0093                                     const DDStringArguments& sArgs,
0094                                     const DDStringVectorArguments& vsArgs) {
0095   int i;
0096   DDName parentName = parent().name();
0097   detectorN = (int)(nArgs["DetectorNumber"]);
0098 
0099   LogDebug("TIDGeom") << "DDTIDModulePosAlgo debug: Parent " << parentName << " Detector Planes " << detectorN;
0100 
0101   detTilt = nArgs["DetTilt"];
0102   fullHeight = nArgs["FullHeight"];
0103   dlTop = nArgs["DlTop"];
0104   dlBottom = nArgs["DlBottom"];
0105   dlHybrid = nArgs["DlHybrid"];
0106 
0107   LogDebug("TIDGeom") << "DDTIDModulePosAlgo debug: Detector Tilt " << detTilt / CLHEP::deg << " Height " << fullHeight
0108                       << " dl(Top) " << dlTop << " dl(Bottom) " << dlBottom << " dl(Hybrid) " << dlHybrid;
0109 
0110   boxFrameName = sArgs["BoxFrameName"];
0111   boxFrameHeight = nArgs["BoxFrameHeight"];
0112   boxFrameWidth = nArgs["BoxFrameWidth"];
0113   boxFrameZ = vArgs["BoxFrameZ"];
0114   bottomFrameHeight = nArgs["BottomFrameHeight"];
0115   bottomFrameOver = nArgs["BottomFrameOver"];
0116   topFrameHeight = nArgs["TopFrameHeight"];
0117   topFrameOver = nArgs["TopFrameOver"];
0118   LogDebug("TIDGeom") << "DDTIDModulePosAlgo debug: " << boxFrameName << " positioned at Z";
0119   for (i = 0; i < detectorN; i++)
0120     LogDebug("TIDGeom") << "\tboxFrameZ[" << i << "] = " << boxFrameZ[i];
0121   LogDebug("TIDGeom") << "\t Extra Height at Bottom " << bottomFrameHeight << " Overlap " << bottomFrameOver;
0122 
0123   sideFrameName = vsArgs["SideFrameName"];
0124   sideFrameZ = vArgs["SideFrameZ"];
0125   sideFrameRot = vsArgs["SideFrameRotation"];
0126   sideFrameWidth = nArgs["SideFrameWidth"];
0127   sideFrameOver = nArgs["SideFrameOver"];
0128   for (i = 0; i < detectorN; i++)
0129     LogDebug("TIDGeom") << "\tsideFrame[" << i << "] = " << sideFrameName[i] << " positioned at Z " << sideFrameZ[i]
0130                         << " with rotation " << sideFrameRot[i];
0131 
0132   kaptonName = vsArgs["KaptonName"];
0133   kaptonZ = vArgs["KaptonZ"];
0134   kaptonRot = vsArgs["KaptonRotation"];
0135   for (i = 0; i < detectorN; i++)
0136     LogDebug("TIDGeom") << "\tkapton[" << i << "] = " << kaptonName[i] << " positioned at Z " << kaptonZ[i]
0137                         << " with rotation " << kaptonRot[i];
0138 
0139   waferName = vsArgs["WaferName"];
0140   waferZ = vArgs["WaferZ"];
0141   waferRot = vsArgs["WaferRotation"];
0142   for (i = 0; i < detectorN; i++)
0143     LogDebug("TIDGeom") << "DDTIDModulePosAlgo debug: " << waferName[i] << " positioned at Z " << waferZ[i]
0144                         << " with rotation " << waferRot[i];
0145 
0146   hybridName = sArgs["HybridName"];
0147   hybridHeight = nArgs["HybridHeight"];
0148   hybridZ = vArgs["HybridZ"];
0149   LogDebug("TIDGeom") << "DDTIDModulePosAlgo debug: " << hybridName << " Height " << hybridHeight << " Z";
0150   for (i = 0; i < detectorN; i++)
0151     LogDebug("TIDGeom") << "\thybridZ[" << i << "] = " << hybridZ[i];
0152 
0153   pitchName = vsArgs["PitchName"];
0154   pitchHeight = nArgs["PitchHeight"];
0155   pitchZ = vArgs["PitchZ"];
0156   pitchRot = vsArgs["PitchRotation"];
0157   LogDebug("TIDGeom") << "DDTIDModulePosAlgo debug: Pitch Adapter Height " << pitchHeight;
0158   for (i = 0; i < detectorN; i++)
0159     LogDebug("TIDGeom") << "DDTIDModulePosAlgo debug: " << pitchName[i] << " position at Z " << pitchZ[i]
0160                         << " with rotation " << pitchRot[i];
0161 
0162   coolName = sArgs["CoolInsertName"];
0163   coolHeight = nArgs["CoolInsertHeight"];
0164   coolZ = nArgs["CoolInsertZ"];
0165   coolWidth = nArgs["CoolInsertWidth"];
0166   coolRadShift = vArgs["CoolInsertShift"];
0167 
0168   string comp = sArgs["DoSpacers"];
0169   if (comp == "No" || comp == "NO" || comp == "no")
0170     doSpacers = false;
0171   else
0172     doSpacers = true;
0173 
0174   botSpacersName = sArgs["BottomSpacersName"];
0175   botSpacersHeight = nArgs["BottomSpacersHeight"];
0176   botSpacersZ = nArgs["BottomSpacersZ"];
0177   sidSpacersName = sArgs["SideSpacersName"];
0178   sidSpacersHeight = nArgs["SideSpacersHeight"];
0179   sidSpacersZ = nArgs["SideSpacersZ"];
0180   sidSpacersWidth = nArgs["SideSpacersWidth"];
0181   sidSpacersRadShift = nArgs["SideSpacersShift"];
0182 }
0183 
0184 void DDTIDModulePosAlgo::execute(DDCompactView& cpv) {
0185   LogDebug("TIDGeom") << "==>> Constructing DDTIDModulePosAlgo...";
0186 
0187   DDName parentName = parent().name();
0188 
0189   double botfr;  // width of side frame at the the bottom of the modules
0190   double topfr;  // width of side frame at the the top of the modules
0191   double kaptonHeight;
0192   if (dlHybrid > dlTop) {
0193     // ring 1, ring 2
0194     topfr = topFrameHeight - pitchHeight - topFrameOver;
0195     botfr = bottomFrameHeight - bottomFrameOver;
0196     kaptonHeight = fullHeight + botfr;
0197   } else {
0198     // ring 3
0199     topfr = topFrameHeight - topFrameOver;
0200     botfr = bottomFrameHeight - bottomFrameOver - pitchHeight;
0201     kaptonHeight = fullHeight + topfr;
0202   }
0203 
0204   double sideFrameHeight = fullHeight + pitchHeight + botfr + topfr;
0205   double zCenter = 0.5 * (sideFrameHeight + boxFrameHeight);
0206 
0207   // (Re) Compute the envelope for positioning Cool Inserts and Side Spacers (Alumina).
0208   double sidfr = sideFrameWidth - sideFrameOver;  // width of side frame on the sides of module
0209   double dxbot = 0.5 * dlBottom + sidfr;
0210   double dxtop = 0.5 * dlTop + sidfr;
0211   double dxtopenv, dxbotenv;  // top/bot width of the module envelope trap
0212 
0213   double tanWafer = (dxtop - dxbot) / fullHeight;  //
0214   double thetaWafer = atan(tanWafer);              // 1/2 of the wafer wedge angle
0215 
0216   if (dlHybrid > dlTop) {
0217     // ring 1, ring 2
0218     dxtopenv = dxbot + (dxtop - dxbot) * (fullHeight + pitchHeight + topfr + hybridHeight) / fullHeight;
0219     dxbotenv = dxtop - (dxtop - dxbot) * (fullHeight + botfr) / fullHeight;
0220   } else {
0221     // ring 3
0222     dxtopenv = dxbot + (dxtop - dxbot) * (fullHeight + topfr) / fullHeight;
0223     dxbotenv = dxbot;
0224   }
0225 
0226   double tanEnv = (dxtopenv - dxbotenv) / (sideFrameHeight + boxFrameHeight);  // 1/2 of the envelope wedge angle
0227 
0228   double xpos = 0;
0229   double ypos = 0;
0230   double zpos = 0;
0231 
0232   // Cool Inserts
0233   DDName name = DDName(DDSplit(coolName).first, DDSplit(coolName).second);
0234   ypos = coolZ;
0235 
0236   double zCool;
0237   int copy = 0;
0238   DDRotation rot = DDRotation();  // should be different for different elements
0239 
0240   for (int j1 = 0; j1 < 2; j1++) {  // j1: 0 inserts below the hybrid
0241                                     //     1 inserts below the wafer
0242     if (dlHybrid > dlTop) {
0243       zCool = sideFrameHeight + boxFrameHeight - coolRadShift[j1];
0244       if (j1 == 0)
0245         zCool -= 0.5 * coolHeight;
0246     } else {
0247       zCool = coolRadShift[j1];
0248       if (j1 == 0)
0249         zCool += 0.5 * coolHeight;
0250     }
0251 
0252     if (j1 == 0) {
0253       xpos = -0.5 * (boxFrameWidth - coolWidth);
0254     } else {
0255       xpos = -(dxbotenv + (zCool - 0.5 * coolHeight) * tanEnv - 0.5 * coolWidth);
0256     }
0257 
0258     zpos = zCool - zCenter;
0259     for (int j2 = 0; j2 < 2; j2++) {
0260       copy++;
0261       cpv.position(name, parentName, copy, DDTranslation(xpos, ypos, zpos), rot);
0262       LogDebug("TIDGeom") << "DDTIDModulePosAlgo test: " << name << " number " << copy << " positioned in "
0263                           << parentName << " at " << DDTranslation(xpos, ypos, zpos) << " with " << rot;
0264       xpos = -xpos;
0265     }
0266   }
0267 
0268   if (doSpacers) {
0269     // Bottom Spacers (Alumina)
0270     DDName name = DDName(DDSplit(botSpacersName).first, DDSplit(botSpacersName).second);
0271     ypos = botSpacersZ;
0272 
0273     double zBotSpacers;
0274     if (dlHybrid > dlTop) {
0275       zBotSpacers = sideFrameHeight + boxFrameHeight - 0.5 * botSpacersHeight;
0276     } else {
0277       zBotSpacers = 0.5 * botSpacersHeight;
0278     }
0279     zpos = zBotSpacers - zCenter;
0280     rot = DDRotation();
0281     cpv.position(name, parentName, 1, DDTranslation(0.0, ypos, zpos), rot);
0282     LogDebug("TIDGeom") << "DDTIDModulePosAlgo test: " << name << " number " << 1 << " positioned in " << parentName
0283                         << " at " << DDTranslation(0.0, ypos, zpos) << " with no rotation";
0284 
0285     // Side Spacers (Alumina)
0286     name = DDName(DDSplit(sidSpacersName).first, DDSplit(sidSpacersName).second);
0287     ypos = sidSpacersZ;
0288 
0289     double zSideSpacers;
0290     if (dlHybrid > dlTop) {
0291       zSideSpacers = sideFrameHeight + boxFrameHeight - sidSpacersRadShift;
0292     } else {
0293       zSideSpacers = sidSpacersRadShift;
0294     }
0295     zpos = zSideSpacers - zCenter;
0296 
0297     copy = 0;
0298     xpos = dxbotenv + (zSideSpacers - 0.5 * sidSpacersHeight) * tanEnv - 0.5 * sidSpacersWidth + sideFrameOver;
0299 
0300     double phix, phiy, phiz;
0301     phix = 0. * CLHEP::deg;
0302     phiy = 90. * CLHEP::deg;
0303     phiz = 0. * CLHEP::deg;
0304 
0305     double thetay, thetax;
0306     thetay = 90. * CLHEP::deg;
0307     double thetaz = thetaWafer;
0308 
0309     for (int j1 = 0; j1 < 2; j1++) {
0310       copy++;
0311 
0312       // tilt Side Spacers (parallel to Side Frame)
0313       thetax = 90. * CLHEP::deg + thetaz;
0314       double thetadeg = thetax / CLHEP::deg;
0315       if (thetadeg != 0) {
0316         string arotstr = DDSplit(sidSpacersName).first + to_string(thetadeg * 10.);
0317         rot = DDrot(DDName(arotstr, DDSplit(sidSpacersName).second), thetax, phix, thetay, phiy, thetaz, phiz);
0318       }
0319 
0320       cpv.position(name, parentName, copy, DDTranslation(xpos, ypos, zpos), rot);
0321       LogDebug("TIDGeom") << "DDTIDModulePosAlgo test: " << name << " number " << copy << " positioned in "
0322                           << parentName << " at " << DDTranslation(xpos, ypos, zpos) << " with " << rot;
0323       xpos = -xpos;
0324       thetaz = -thetaz;
0325     }
0326   }
0327 
0328   // Loop over detectors to be placed
0329   for (int k = 0; k < detectorN; k++) {
0330     // Wafer
0331     name = DDName(DDSplit(waferName[k]).first, DDSplit(waferName[k]).second);
0332     xpos = 0;
0333     ypos = waferZ[k];
0334     double zWafer;
0335     if (dlHybrid > dlTop) {
0336       zWafer = botfr + 0.5 * fullHeight;
0337     } else {
0338       zWafer = boxFrameHeight + botfr + pitchHeight + 0.5 * fullHeight;
0339     }
0340     zpos = zWafer - zCenter;
0341     DDTranslation tran(xpos, ypos, zpos);
0342     string rotstr = DDSplit(waferRot[k]).first;
0343     string rotns;
0344     if (rotstr != "NULL") {
0345       rotns = DDSplit(waferRot[k]).second;
0346       rot = DDRotation(DDName(rotstr, rotns));
0347     }
0348     cpv.position(name, parentName, k + 1, tran, rot);
0349     LogDebug("TIDGeom") << "DDTIDModulePosAlgo test: " << name << " number " << k + 1 << " positioned in " << parentName
0350                         << " at " << tran << " with " << rot;
0351 
0352     //Pitch Adapter
0353     name = DDName(DDSplit(pitchName[k]).first, DDSplit(pitchName[k]).second);
0354     if (k == 0) {
0355       xpos = 0;
0356     } else {
0357       xpos = 0.5 * fullHeight * sin(detTilt);
0358     }
0359     ypos = pitchZ[k];
0360     double zPitch;
0361     if (dlHybrid > dlTop) {
0362       zPitch = botfr + fullHeight + 0.5 * pitchHeight;
0363     } else {
0364       zPitch = boxFrameHeight + botfr + 0.5 * pitchHeight;
0365     }
0366     zpos = zPitch - zCenter;
0367     rotstr = DDSplit(pitchRot[k]).first;
0368     if (rotstr != "NULL") {
0369       rotns = DDSplit(pitchRot[k]).second;
0370       rot = DDRotation(DDName(rotstr, rotns));
0371     } else {
0372       rot = DDRotation();
0373     }
0374     tran = DDTranslation(xpos, ypos, zpos);
0375     cpv.position(name, parentName, k + 1, tran, rot);
0376     LogDebug("TIDGeom") << "DDTIDModulePosAlgo test: " << name << " number " << k + 1 << " positioned in " << parentName
0377                         << " at " << tran << " with " << rot;
0378 
0379     // Hybrid
0380     name = DDName(DDSplit(hybridName).first, DDSplit(hybridName).second);
0381     ypos = hybridZ[k];
0382     double zHybrid;
0383     if (dlHybrid > dlTop) {
0384       zHybrid = botfr + fullHeight + pitchHeight + 0.5 * hybridHeight;
0385     } else {
0386       zHybrid = 0.5 * hybridHeight;
0387     }
0388     zpos = zHybrid - zCenter;
0389     tran = DDTranslation(0, ypos, zpos);
0390     rot = DDRotation();
0391     cpv.position(name, parentName, k + 1, tran, rot);
0392     LogDebug("TIDGeom") << "DDTIDModulePosAlgo test: " << name << " number " << k + 1 << " positioned in " << parentName
0393                         << " at " << tran << " with " << rot;
0394 
0395     // Box frame
0396     name = DDName(DDSplit(boxFrameName).first, DDSplit(boxFrameName).second);
0397     ypos = boxFrameZ[k];
0398     double zBoxFrame;
0399     if (dlHybrid > dlTop) {
0400       zBoxFrame = sideFrameHeight + 0.5 * boxFrameHeight;
0401     } else {
0402       zBoxFrame = 0.5 * boxFrameHeight;
0403     }
0404     zpos = zBoxFrame - zCenter;
0405     tran = DDTranslation(0, ypos, zpos);
0406     rot = DDRotation();
0407     cpv.position(name, parentName, k + 1, tran, rot);
0408     LogDebug("TIDGeom") << "DDTIDModulePosAlgo test: " << name << " number " << k + 1 << " positioned in " << parentName
0409                         << " at " << tran << " with " << rot;
0410 
0411     // Side frame
0412     name = DDName(DDSplit(sideFrameName[k]).first, DDSplit(sideFrameName[k]).second);
0413     ypos = sideFrameZ[k];
0414     double zSideFrame;
0415     if (dlHybrid > dlTop) {
0416       zSideFrame = 0.5 * sideFrameHeight;
0417     } else {
0418       zSideFrame = boxFrameHeight + 0.5 * sideFrameHeight;
0419     }
0420     zpos = zSideFrame - zCenter;
0421     rotstr = DDSplit(sideFrameRot[k]).first;
0422     if (rotstr != "NULL") {
0423       rotns = DDSplit(sideFrameRot[k]).second;
0424       rot = DDRotation(DDName(rotstr, rotns));
0425     } else {
0426       rot = DDRotation();
0427     }
0428     tran = DDTranslation(0, ypos, zpos);
0429     cpv.position(name, parentName, k + 1, tran, rot);
0430     LogDebug("TIDGeom") << "DDTIDModulePosAlgo test: " << name << " number " << k + 1 << " positioned in " << parentName
0431                         << " at " << tran << " with " << rot;
0432 
0433     // Kapton circuit
0434     name = DDName(DDSplit(kaptonName[k]).first, DDSplit(kaptonName[k]).second);
0435     ypos = kaptonZ[k];
0436     double zKapton;
0437     double kaptonExtraHeight = 0;
0438     if (dlHybrid > dlTop) {
0439       if (k == 1)
0440         kaptonExtraHeight = dlTop * sin(detTilt) - fullHeight * (1 - cos(detTilt));
0441       kaptonExtraHeight = 0.5 * fabs(kaptonExtraHeight);
0442       zKapton = 0.5 * (kaptonHeight + kaptonExtraHeight);
0443     } else {
0444       if (k == 1)
0445         kaptonExtraHeight = dlBottom * sin(detTilt) - fullHeight * (1 - cos(detTilt));
0446       kaptonExtraHeight = 0.5 * fabs(kaptonExtraHeight);
0447       zKapton = boxFrameHeight + sideFrameHeight - 0.5 * (kaptonHeight + kaptonExtraHeight);
0448     }
0449     zpos = zKapton - zCenter;
0450     rotstr = DDSplit(kaptonRot[k]).first;
0451     if (rotstr != "NULL") {
0452       rotns = DDSplit(kaptonRot[k]).second;
0453       rot = DDRotation(DDName(rotstr, rotns));
0454     } else {
0455       rot = DDRotation();
0456     }
0457     tran = DDTranslation(0, ypos, zpos);
0458     cpv.position(name, parentName, k + 1, tran, rot);
0459     LogDebug("TIDGeom") << "DDTIDModulePosAlgo test: " << name << " number " << k + 1 << " positioned in " << parentName
0460                         << " at " << tran << " with " << rot;
0461   }
0462 
0463   LogDebug("TIDGeom") << "<<== End of DDTIDModulePosAlgo positioning ...";
0464 }
0465 
0466 DEFINE_EDM_PLUGIN(DDAlgorithmFactory, DDTIDModulePosAlgo, "track:DDTIDModulePosAlgo");