Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-05-10 02:20:54

0001 ///////////////////////////////////////////////////////////////////////////////
0002 // File: DDTIDModuleAlgo.cc
0003 // Description: Creation of a TID Module
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/SystemOfUnits.h>
0017 
0018 #include <string>
0019 #include <vector>
0020 
0021 using namespace std;
0022 
0023 class DDTIDModuleAlgo : public DDAlgorithm {
0024 public:
0025   //Constructor and Destructor
0026   DDTIDModuleAlgo();
0027   ~DDTIDModuleAlgo() override;
0028 
0029   void initialize(const DDNumericArguments& nArgs,
0030                   const DDVectorArguments& vArgs,
0031                   const DDMapArguments& mArgs,
0032                   const DDStringArguments& sArgs,
0033                   const DDStringVectorArguments& vsArgs) override;
0034 
0035   void execute(DDCompactView& cpv) override;
0036 
0037 private:
0038   string genMat;       //General material name
0039   int detectorN;       //Detector planes
0040   double moduleThick;  //Module thickness
0041   double detTilt;      //Tilt of stereo detector
0042   double fullHeight;   //Height
0043   double dlTop;        //Width at top of wafer
0044   double dlBottom;     //Width at bottom of wafer
0045   double dlHybrid;     //Width at the hybrid end
0046   bool doComponents;   //Components to be made
0047 
0048   string boxFrameName;           //Top frame     name
0049   string boxFrameMat;            //              material
0050   double boxFrameHeight;         //              height
0051   double boxFrameThick;          //              thickness
0052   double boxFrameWidth;          //              extra width
0053   double bottomFrameHeight;      //Bottom of the frame
0054   double bottomFrameOver;        //              overlap
0055   double topFrameHeight;         //Top    of the frame
0056   double topFrameOver;           //              overlap
0057   vector<string> sideFrameName;  //Side frame    name
0058   string sideFrameMat;           //              material
0059   double sideFrameWidth;         //              width
0060   double sideFrameThick;         //              thickness
0061   double sideFrameOver;          //              overlap (wrt wafer)
0062   vector<string> holeFrameName;  //Hole in the frame   name
0063   vector<string> holeFrameRot;   //              Rotation matrix
0064 
0065   vector<string> kaptonName;  //Kapton circuit name
0066   string kaptonMat;           //               material
0067   //  double                   kaptonWidth;   //               width -> computed internally from sideFrameWidth and kaptonOver
0068   double kaptonThick;             //               thickness
0069   double kaptonOver;              //               overlap (wrt Wafer)
0070   vector<string> holeKaptonName;  //Hole in the kapton circuit name
0071   vector<string> holeKaptonRot;   //              Rotation matrix
0072 
0073   vector<string> waferName;       //Wafer         name
0074   string waferMat;                //              material
0075   double sideWidthTop;            //              width on the side Top
0076   double sideWidthBottom;         //                                Bottom
0077   vector<string> activeName;      //Sensitive     name
0078   string activeMat;               //              material
0079   double activeHeight;            //              height
0080   vector<double> waferThick;      //              wafer thickness (active = wafer - backplane)
0081   string activeRot;               //              Rotation matrix
0082   vector<double> backplaneThick;  //              thickness
0083   string hybridName;              //Hybrid        name
0084   string hybridMat;               //              material
0085   double hybridHeight;            //              height
0086   double hybridWidth;             //              width
0087   double hybridThick;             //              thickness
0088   vector<string> pitchName;       //Pitch adapter name
0089   string pitchMat;                //              material
0090   double pitchHeight;             //              height
0091   double pitchThick;              //              thickness
0092   double pitchStereoTol;          //              tolerance in dimensions of the stereo
0093   string coolName;                // Cool insert name
0094   string coolMat;                 //              material
0095   double coolHeight;              //              height
0096   double coolThick;               //              thickness
0097   double coolWidth;               //              width
0098 };
0099 
0100 DDTIDModuleAlgo::DDTIDModuleAlgo() { LogDebug("TIDGeom") << "DDTIDModuleAlgo info: Creating an instance"; }
0101 
0102 DDTIDModuleAlgo::~DDTIDModuleAlgo() {}
0103 
0104 void DDTIDModuleAlgo::initialize(const DDNumericArguments& nArgs,
0105                                  const DDVectorArguments& vArgs,
0106                                  const DDMapArguments&,
0107                                  const DDStringArguments& sArgs,
0108                                  const DDStringVectorArguments& vsArgs) {
0109   int i;
0110   genMat = sArgs["GeneralMaterial"];
0111   detectorN = (int)(nArgs["DetectorNumber"]);
0112   DDName parentName(parent().name());
0113 
0114   LogDebug("TIDGeom") << "DDTIDModuleAlgo debug: Parent " << parentName << " General Material " << genMat
0115                       << " Detector Planes " << detectorN;
0116 
0117   moduleThick = nArgs["ModuleThick"];
0118   detTilt = nArgs["DetTilt"];
0119   fullHeight = nArgs["FullHeight"];
0120   dlTop = nArgs["DlTop"];
0121   dlBottom = nArgs["DlBottom"];
0122   dlHybrid = nArgs["DlHybrid"];
0123   string comp = sArgs["DoComponents"];
0124   if (comp == "No" || comp == "NO" || comp == "no")
0125     doComponents = false;
0126   else
0127     doComponents = true;
0128 
0129   LogDebug("TIDGeom") << "DDTIDModuleAlgo debug: ModuleThick " << moduleThick << " Detector Tilt "
0130                       << detTilt / CLHEP::deg << " Height " << fullHeight << " dl(Top) " << dlTop << " dl(Bottom) "
0131                       << dlBottom << " dl(Hybrid) " << dlHybrid << " doComponents " << doComponents;
0132 
0133   boxFrameName = sArgs["BoxFrameName"];
0134   boxFrameMat = sArgs["BoxFrameMaterial"];
0135   boxFrameThick = nArgs["BoxFrameThick"];
0136   boxFrameHeight = nArgs["BoxFrameHeight"];
0137   boxFrameWidth = nArgs["BoxFrameWidth"];
0138   bottomFrameHeight = nArgs["BottomFrameHeight"];
0139   bottomFrameOver = nArgs["BottomFrameOver"];
0140   LogDebug("TIDGeom") << "DDTIDModuleAlgo debug: " << boxFrameName << " Material " << boxFrameMat << " Thickness "
0141                       << boxFrameThick << " width " << boxFrameWidth << " height " << boxFrameHeight
0142                       << " Extra Height at Bottom " << bottomFrameHeight << " Overlap " << bottomFrameOver;
0143 
0144   topFrameHeight = nArgs["TopFrameHeight"];
0145   topFrameOver = nArgs["TopFrameOver"];
0146   sideFrameName = vsArgs["SideFrameName"];
0147   sideFrameMat = sArgs["SideFrameMaterial"];
0148   sideFrameWidth = nArgs["SideFrameWidth"];
0149   sideFrameThick = nArgs["SideFrameThick"];
0150   sideFrameOver = nArgs["SideFrameOver"];
0151   holeFrameName = vsArgs["HoleFrameName"];
0152   holeFrameRot = vsArgs["HoleFrameRotation"];
0153   for (i = 0; i < detectorN; i++)
0154     LogDebug("TIDGeom") << "DDTIDModuleAlgo debug : " << sideFrameName[i] << " Material " << sideFrameMat << " Width "
0155                         << sideFrameWidth << " Thickness " << sideFrameThick << " Overlap " << sideFrameOver
0156                         << " Hole  " << holeFrameName[i];
0157 
0158   kaptonName = vsArgs["KaptonName"];
0159   kaptonMat = sArgs["KaptonMaterial"];
0160   kaptonThick = nArgs["KaptonThick"];
0161   kaptonOver = nArgs["KaptonOver"];
0162   holeKaptonName = vsArgs["HoleKaptonName"];
0163   holeKaptonRot = vsArgs["HoleKaptonRotation"];
0164   for (i = 0; i < detectorN; i++)
0165     LogDebug("TIDGeom") << "DDTIDModuleAlgo debug : " << kaptonName[i] << " Material " << kaptonMat << " Thickness "
0166                         << kaptonThick << " Overlap " << kaptonOver << " Hole  " << holeKaptonName[i];
0167 
0168   waferName = vsArgs["WaferName"];
0169   waferMat = sArgs["WaferMaterial"];
0170   sideWidthTop = nArgs["SideWidthTop"];
0171   sideWidthBottom = nArgs["SideWidthBottom"];
0172 
0173   LogDebug("TIDGeom") << "DDTIDModuleAlgo debug: Wafer Material " << waferMat << " Side Width Top " << sideWidthTop
0174                       << " Side Width Bottom " << sideWidthBottom;
0175   for (i = 0; i < detectorN; i++)
0176     LogDebug("TIDGeom") << "\twaferName[" << i << "] = " << waferName[i];
0177 
0178   activeName = vsArgs["ActiveName"];
0179   activeMat = sArgs["ActiveMaterial"];
0180   activeHeight = nArgs["ActiveHeight"];
0181   waferThick = vArgs["WaferThick"];
0182   activeRot = sArgs["ActiveRotation"];
0183   backplaneThick = vArgs["BackPlaneThick"];
0184   LogDebug("TIDGeom") << "DDTIDModuleAlgo debug: Active Material " << activeMat << " Height " << activeHeight
0185                       << " rotated by " << activeRot;
0186   for (i = 0; i < detectorN; i++)
0187     LogDebug("TIDGeom") << " translated by (0," << -0.5 * backplaneThick[i] << ",0)\tactiveName[" << i
0188                         << "] = " << activeName[i] << " of thickness " << waferThick[i] - backplaneThick[i];
0189 
0190   hybridName = sArgs["HybridName"];
0191   hybridMat = sArgs["HybridMaterial"];
0192   hybridHeight = nArgs["HybridHeight"];
0193   hybridWidth = nArgs["HybridWidth"];
0194   hybridThick = nArgs["HybridThick"];
0195   LogDebug("TIDGeom") << "DDTIDModuleAlgo debug: " << hybridName << " Material " << hybridMat << " Height "
0196                       << hybridHeight << " Width " << hybridWidth << " Thickness " << hybridThick;
0197 
0198   pitchName = vsArgs["PitchName"];
0199   pitchMat = sArgs["PitchMaterial"];
0200   pitchHeight = nArgs["PitchHeight"];
0201   pitchThick = nArgs["PitchThick"];
0202   pitchStereoTol = nArgs["PitchStereoTolerance"];
0203 
0204   LogDebug("TIDGeom") << "DDTIDModuleAlgo debug: Pitch Adapter Material " << pitchMat << " Height " << pitchHeight
0205                       << " Thickness " << pitchThick;
0206   for (i = 0; i < detectorN; i++)
0207     LogDebug("TIDGeom") << "\tpitchName[" << i << "] = " << pitchName[i];
0208 
0209   coolName = sArgs["CoolInsertName"];
0210   coolMat = sArgs["CoolInsertMaterial"];
0211   coolHeight = nArgs["CoolInsertHeight"];
0212   coolThick = nArgs["CoolInsertThick"];
0213   coolWidth = nArgs["CoolInsertWidth"];
0214   LogDebug("TIDGeom") << "DDTIDModuleAlgo debug: Cool Element Material " << coolMat << " Height " << coolHeight
0215                       << " Thickness " << coolThick << " Width " << coolWidth;
0216 }
0217 
0218 void DDTIDModuleAlgo::execute(DDCompactView& cpv) {
0219   LogDebug("TIDGeom") << "==>> Constructing DDTIDModuleAlgo...";
0220 
0221   DDName parentName(parent().name());
0222 
0223   double sidfr = sideFrameWidth - sideFrameOver;  // width of side frame on the sides of module
0224   double botfr;                                   // width of side frame at the the bottom of the modules
0225   double topfr;                                   // width of side frame at the the top of the modules
0226   double kaptonHeight;
0227   if (dlHybrid > dlTop) {
0228     // ring 1, ring 2
0229     topfr = topFrameHeight - pitchHeight - topFrameOver;
0230     botfr = bottomFrameHeight - bottomFrameOver;
0231     kaptonHeight = fullHeight + botfr;
0232   } else {
0233     // ring 3
0234     topfr = topFrameHeight - topFrameOver;
0235     botfr = bottomFrameHeight - bottomFrameOver - pitchHeight;
0236     kaptonHeight = fullHeight + topfr;
0237   }
0238 
0239   double sideFrameHeight = fullHeight + pitchHeight + botfr + topfr;
0240   double kaptonWidth = sidfr + kaptonOver;
0241 
0242   double dxbot = 0.5 * dlBottom + sidfr;
0243   double dxtop = 0.5 * dlTop + sidfr;
0244   double dxtopenv, dxbotenv;  // top/bot width of the module envelope trap
0245 
0246   // Envelope
0247   if (dlHybrid > dlTop) {
0248     // ring 1, ring 2
0249     dxtopenv = dxbot + (dxtop - dxbot) * (fullHeight + pitchHeight + topfr + hybridHeight) / fullHeight;
0250     dxbotenv = dxtop - (dxtop - dxbot) * (fullHeight + botfr) / fullHeight;
0251   } else {
0252     // ring 3
0253     dxtopenv = dxbot + (dxtop - dxbot) * (fullHeight + topfr) / fullHeight;
0254     dxbotenv = dxbot;
0255   }
0256   double bl1 = dxbotenv;
0257   double bl2 = dxtopenv;
0258   double h1 = 0.5 * moduleThick;
0259   double dz = 0.5 * (boxFrameHeight + sideFrameHeight);
0260 
0261   DDSolid solidUncut, solidCut;
0262   DDSolid solid = DDSolidFactory::trap(parentName, dz, 0, 0, h1, bl1, bl1, 0, h1, bl2, bl2, 0);
0263   DDMaterial matter = DDMaterial(DDName(DDSplit(genMat).first, DDSplit(genMat).second));
0264   DDLogicalPart module(solid.ddname(), matter, solid);
0265   LogDebug("TIDGeom") << "DDTIDModuleAlgo test:\t" << solid.name() << " Trap made of " << genMat << " of dimensions "
0266                       << dz << ", 0, 0, " << h1 << ", " << bl1 << ", " << bl1 << ", 0, " << h1 << ", " << bl2 << ", "
0267                       << bl2 << ", 0";
0268 
0269   if (doComponents) {
0270     //Box frame
0271     matter = DDMaterial(DDName(DDSplit(boxFrameMat).first, DDSplit(boxFrameMat).second));
0272     double dx = 0.5 * boxFrameWidth;
0273     double dy = 0.5 * boxFrameThick;
0274     double dz = 0.5 * boxFrameHeight;
0275     solid = DDSolidFactory::box(DDName(DDSplit(boxFrameName).first, DDSplit(boxFrameName).second), dx, dy, dz);
0276     LogDebug("TIDGeom") << "DDTIDModuleAlgo test:\t" << solid.name() << " Box made of " << matter.ddname()
0277                         << " of dimensions " << dx << ", " << dy << ", " << dz;
0278     DDLogicalPart boxFrame(solid.ddname(), matter, solid);
0279 
0280     // Hybrid
0281     matter = DDMaterial(DDName(DDSplit(hybridMat).first, DDSplit(hybridMat).second));
0282     dx = 0.5 * hybridWidth;
0283     dy = 0.5 * hybridThick;
0284     dz = 0.5 * hybridHeight;
0285     solid = DDSolidFactory::box(DDName(DDSplit(hybridName).first, DDSplit(hybridName).second), dx, dy, dz);
0286     LogDebug("TIDGeom") << "DDTIDModuleAlgo test:\t" << solid.name() << " Box made of " << matter.ddname()
0287                         << " of dimensions " << dx << ", " << dy << ", " << dz;
0288     DDLogicalPart hybrid(solid.ddname(), matter, solid);
0289 
0290     // Cool Insert
0291     matter = DDMaterial(DDName(DDSplit(coolMat).first, DDSplit(coolMat).second));
0292     dx = 0.5 * coolWidth;
0293     dy = 0.5 * coolThick;
0294     dz = 0.5 * coolHeight;
0295     solid = DDSolidFactory::box(DDName(DDSplit(coolName).first, DDSplit(coolName).second), dx, dy, dz);
0296     LogDebug("TIDGeom") << "DDTIDModuleAlgo test:\t" << solid.name() << " Box made of " << matter.ddname()
0297                         << " of dimensions " << dx << ", " << dy << ", " << dz;
0298     DDLogicalPart cool(solid.ddname(), matter, solid);
0299 
0300     // Loop over detectors to be placed
0301     for (int k = 0; k < detectorN; k++) {
0302       double bbl1, bbl2;  // perhaps useless (bl1 enough)
0303 
0304       // Frame Sides
0305       matter = DDMaterial(DDName(DDSplit(sideFrameMat).first, DDSplit(sideFrameMat).second));
0306       if (dlHybrid > dlTop) {
0307         // ring 1, ring 2
0308         bbl1 = dxtop - (dxtop - dxbot) * (fullHeight + botfr) / fullHeight;
0309         bbl2 = dxbot + (dxtop - dxbot) * (fullHeight + pitchHeight + topfr) / fullHeight;
0310       } else {
0311         // ring 3
0312         bbl1 = dxtop - (dxtop - dxbot) * (fullHeight + pitchHeight + botfr) / fullHeight;
0313         bbl2 = dxbot + (dxtop - dxbot) * (fullHeight + topfr) / fullHeight;
0314       }
0315       h1 = 0.5 * sideFrameThick;
0316       dz = 0.5 * sideFrameHeight;
0317       solid = DDSolidFactory::trap(DDName(DDSplit(sideFrameName[k]).first, DDSplit(sideFrameName[k]).second),
0318                                    dz,
0319                                    0,
0320                                    0,
0321                                    h1,
0322                                    bbl1,
0323                                    bbl1,
0324                                    0,
0325                                    h1,
0326                                    bbl2,
0327                                    bbl2,
0328                                    0);
0329       LogDebug("TIDGeom") << "DDTIDModuleAlgo test:\t" << solid.name() << " Trap made of " << matter.ddname()
0330                           << " of dimensions " << dz << ", 0, 0, " << h1 << ", " << bbl1 << ", " << bbl1 << ", 0, "
0331                           << h1 << ", " << bbl2 << ", " << bbl2 << ", 0";
0332       DDLogicalPart sideFrame(solid.ddname(), matter, solid);
0333 
0334       string rotstr, rotns;
0335       DDRotation rot;
0336 
0337       // Hole in the frame below the wafer
0338       matter = DDMaterial(DDName(DDSplit(genMat).first, DDSplit(genMat).second));
0339       double xpos, zpos;
0340       dz = fullHeight - bottomFrameOver - topFrameOver;
0341       bbl1 = dxbot - sideFrameWidth + bottomFrameOver * (dxtop - dxbot) / fullHeight;
0342       bbl2 = dxtop - sideFrameWidth - topFrameOver * (dxtop - dxbot) / fullHeight;
0343       if (dlHybrid > dlTop) {
0344         // ring 1, ring 2
0345         zpos = -(topFrameHeight + 0.5 * dz - 0.5 * sideFrameHeight);
0346       } else {
0347         // ring 3
0348         zpos = bottomFrameHeight + 0.5 * dz - 0.5 * sideFrameHeight;
0349       }
0350       dz /= 2.;
0351       solid = DDSolidFactory::trap(DDName(DDSplit(holeFrameName[k]).first, DDSplit(holeFrameName[k]).second),
0352                                    dz,
0353                                    0,
0354                                    0,
0355                                    h1,
0356                                    bbl1,
0357                                    bbl1,
0358                                    0,
0359                                    h1,
0360                                    bbl2,
0361                                    bbl2,
0362                                    0);
0363       LogDebug("TIDGeom") << "DDTIDModuleAlgo test:\t" << solid.name() << " Trap made of " << matter.ddname()
0364                           << " of dimensions " << dz << ", 0, 0, " << h1 << ", " << bbl1 << ", " << bbl1 << ", 0, "
0365                           << h1 << ", " << bbl2 << ", " << bbl2 << ", 0";
0366       DDLogicalPart holeFrame(solid.ddname(), matter, solid);
0367 
0368       rotstr = DDSplit(holeFrameRot[k]).first;
0369       if (rotstr != "NULL") {
0370         rotns = DDSplit(holeFrameRot[k]).second;
0371         rot = DDRotation(DDName(rotstr, rotns));
0372       } else {
0373         rot = DDRotation();
0374       }
0375       cpv.position(holeFrame, sideFrame, 1, DDTranslation(0.0, 0.0, zpos), rot);
0376       LogDebug("TIDGeom") << "DDTIDModuleAlgo test: " << holeFrame.name() << " number 1 positioned in "
0377                           << sideFrame.name() << " at (0,0," << zpos << ") with no rotation";
0378 
0379       // Kapton circuit
0380       matter = DDMaterial(DDName(DDSplit(kaptonMat).first, DDSplit(kaptonMat).second));
0381       double kaptonExtraHeight = 0;  // kapton extra height in the stereo
0382       if (dlHybrid > dlTop) {
0383         // ring 1, ring 2
0384         bbl1 = dxtop - (dxtop - dxbot) * (fullHeight + botfr) / fullHeight;
0385         if (k == 1) {
0386           kaptonExtraHeight = dlTop * sin(detTilt) - fullHeight * (1 - cos(detTilt));
0387           kaptonExtraHeight = 0.5 * fabs(kaptonExtraHeight);
0388           bbl2 = dxbot + (dxtop - dxbot) * (fullHeight + kaptonExtraHeight) / fullHeight;
0389         } else {
0390           bbl2 = dxtop;
0391         }
0392       } else {
0393         // ring 3
0394         bbl2 = dxbot + (dxtop - dxbot) * (fullHeight + topfr) / fullHeight;
0395         if (k == 1) {
0396           kaptonExtraHeight = dlBottom * sin(detTilt) - fullHeight * (1 - cos(detTilt));
0397           kaptonExtraHeight = 0.5 * fabs(kaptonExtraHeight);
0398           bbl1 = dxtop - (dxtop - dxbot) * (fullHeight + kaptonExtraHeight) / fullHeight;
0399         } else {
0400           bbl1 = dxbot;
0401         }
0402       }
0403       h1 = 0.5 * kaptonThick;
0404       dz = 0.5 * (kaptonHeight + kaptonExtraHeight);
0405 
0406       // For the stereo create the uncut solid, the solid to be removed and then the subtraction solid
0407       if (k == 1) {
0408         // Uncut solid
0409         string kaptonUncutName = kaptonName[k] + "Uncut";
0410         solidUncut = DDSolidFactory::trap(DDName(DDSplit(kaptonUncutName).first, DDSplit(kaptonUncutName).second),
0411                                           dz,
0412                                           0,
0413                                           0,
0414                                           h1,
0415                                           bbl1,
0416                                           bbl1,
0417                                           0,
0418                                           h1,
0419                                           bbl2,
0420                                           bbl2,
0421                                           0);
0422 
0423         // Piece to be cut
0424         string kaptonCutName = kaptonName[k] + "Cut";
0425 
0426         if (dlHybrid > dlTop) {
0427           dz = 0.5 * dlTop;
0428         } else {
0429           dz = 0.5 * dlBottom;
0430         }
0431         h1 = 0.5 * kaptonThick;
0432         bbl1 = fabs(dz * sin(detTilt));
0433         bbl2 = bbl1 * 0.000001;
0434         double thet = atan((bbl1 - bbl2) / (2 * dz));
0435         solidCut = DDSolidFactory::trap(DDName(DDSplit(kaptonCutName).first, DDSplit(kaptonCutName).second),
0436                                         dz,
0437                                         thet,
0438                                         0,
0439                                         h1,
0440                                         bbl1,
0441                                         bbl1,
0442                                         0,
0443                                         h1,
0444                                         bbl2,
0445                                         bbl2,
0446                                         0);
0447 
0448         string aRot("tidmodpar:9PYX");
0449         rotstr = DDSplit(aRot).first;
0450         rotns = DDSplit(aRot).second;
0451         rot = DDRotation(DDName(rotstr, rotns));
0452 
0453         xpos = -0.5 * fullHeight * sin(detTilt);
0454         zpos = 0.5 * kaptonHeight - bbl2;
0455 
0456         // Subtraction Solid
0457         solid = DDSolidFactory::subtraction(DDName(DDSplit(kaptonName[k]).first, DDSplit(kaptonName[k]).second),
0458                                             solidUncut,
0459                                             solidCut,
0460                                             DDTranslation(xpos, 0.0, zpos),
0461                                             rot);
0462       } else {
0463         solid = DDSolidFactory::trap(DDName(DDSplit(kaptonName[k]).first, DDSplit(kaptonName[k]).second),
0464                                      dz,
0465                                      0,
0466                                      0,
0467                                      h1,
0468                                      bbl1,
0469                                      bbl1,
0470                                      0,
0471                                      h1,
0472                                      bbl2,
0473                                      bbl2,
0474                                      0);
0475       }
0476 
0477       DDLogicalPart kapton(solid.ddname(), matter, solid);
0478       LogDebug("TIDGeom") << "DDTIDModuleAlgo test:\t" << solid.name() << " SUBTRACTION SOLID Trap made of "
0479                           << matter.ddname() << " of dimensions " << dz << ", 0, 0, " << h1 << ", " << bbl1 << ", "
0480                           << bbl1 << ", 0, " << h1 << ", " << bbl2 << ", " << bbl2 << ", 0";
0481 
0482       // Hole in the kapton below the wafer
0483       matter = DDMaterial(DDName(DDSplit(genMat).first, DDSplit(genMat).second));
0484       dz = fullHeight - kaptonOver;
0485       xpos = 0;
0486       if (dlHybrid > dlTop) {
0487         // ring 1, ring 2
0488         bbl1 = dxbot - kaptonWidth + kaptonOver * (dxtop - dxbot) / fullHeight;
0489         bbl2 = dxtop - kaptonWidth;
0490         zpos = 0.5 * (kaptonHeight - kaptonExtraHeight - dz);
0491         if (k == 1) {
0492           zpos -= 0.5 * kaptonOver * (1 - cos(detTilt));
0493           xpos = -0.5 * kaptonOver * sin(detTilt);
0494         }
0495       } else {
0496         // ring 3
0497         bbl1 = dxbot - kaptonWidth;
0498         bbl2 = dxtop - kaptonWidth - kaptonOver * (dxtop - dxbot) / fullHeight;
0499         zpos = -0.5 * (kaptonHeight - kaptonExtraHeight - dz);
0500       }
0501       dz /= 2.;
0502       solid = DDSolidFactory::trap(DDName(DDSplit(holeKaptonName[k]).first, DDSplit(holeKaptonName[k]).second),
0503                                    dz,
0504                                    0,
0505                                    0,
0506                                    h1,
0507                                    bbl1,
0508                                    bbl1,
0509                                    0,
0510                                    h1,
0511                                    bbl2,
0512                                    bbl2,
0513                                    0);
0514       LogDebug("TIDGeom") << "DDTIDModuleAlgo test:\t" << solid.name() << " Trap made of " << matter.ddname()
0515                           << " of dimensions " << dz << ", 0, 0, " << h1 << ", " << bbl1 << ", " << bbl1 << ", 0, "
0516                           << h1 << ", " << bbl2 << ", " << bbl2 << ", 0";
0517       DDLogicalPart holeKapton(solid.ddname(), matter, solid);
0518 
0519       rotstr = DDSplit(holeKaptonRot[k]).first;
0520       if (rotstr != "NULL") {
0521         rotns = DDSplit(holeKaptonRot[k]).second;
0522         rot = DDRotation(DDName(rotstr, rotns));
0523       } else {
0524         rot = DDRotation();
0525       }
0526       cpv.position(holeKapton, kapton, 1, DDTranslation(xpos, 0.0, zpos), rot);
0527       LogDebug("TIDGeom") << "DDTIDModuleAlgo test: " << holeKapton.name() << " number 1 positioned in "
0528                           << kapton.name() << " at (0,0," << zpos << ") with no rotation";
0529 
0530       // Wafer
0531       matter = DDMaterial(DDName(DDSplit(waferMat).first, DDSplit(waferMat).second));
0532       if (k == 0 && dlHybrid < dlTop) {
0533         bl1 = 0.5 * dlTop;
0534         bl2 = 0.5 * dlBottom;
0535       } else {
0536         bl1 = 0.5 * dlBottom;
0537         bl2 = 0.5 * dlTop;
0538       }
0539       h1 = 0.5 * waferThick[k];
0540       dz = 0.5 * fullHeight;
0541       solid = DDSolidFactory::trap(
0542           DDName(DDSplit(waferName[k]).first, DDSplit(waferName[k]).second), dz, 0, 0, h1, bl1, bl1, 0, h1, bl2, bl2, 0);
0543       LogDebug("TIDGeom") << "DDTIDModuleAlgo test:\t" << solid.name() << " Trap made of " << matter.ddname()
0544                           << " of dimensions " << dz << ", 0, 0, " << h1 << ", " << bl1 << ", " << bl1 << ", 0, " << h1
0545                           << ", " << bl2 << ", " << bl2 << ", 0";
0546       DDLogicalPart wafer(solid.ddname(), matter, solid);
0547 
0548       // Active
0549       matter = DDMaterial(DDName(DDSplit(activeMat).first, DDSplit(activeMat).second));
0550       if (k == 0 && dlHybrid < dlTop) {
0551         bl1 -= sideWidthTop;
0552         bl2 -= sideWidthBottom;
0553       } else {
0554         bl1 -= sideWidthBottom;
0555         bl2 -= sideWidthTop;
0556       }
0557       dz = 0.5 * (waferThick[k] - backplaneThick[k]);  // inactive backplane
0558       h1 = 0.5 * activeHeight;
0559       solid = DDSolidFactory::trap(DDName(DDSplit(activeName[k]).first, DDSplit(activeName[k]).second),
0560                                    dz,
0561                                    0,
0562                                    0,
0563                                    h1,
0564                                    bl2,
0565                                    bl1,
0566                                    0,
0567                                    h1,
0568                                    bl2,
0569                                    bl1,
0570                                    0);
0571       LogDebug("TIDGeom") << "DDTIDModuleAlgo test:\t" << solid.name() << " Trap made of " << matter.ddname()
0572                           << " of dimensions " << dz << ", 0, 0, " << h1 << ", " << bl2 << ", " << bl1 << ", 0, " << h1
0573                           << ", " << bl2 << ", " << bl1 << ", 0";
0574       DDLogicalPart active(solid.ddname(), matter, solid);
0575       rotstr = DDSplit(activeRot).first;
0576       if (rotstr != "NULL") {
0577         rotns = DDSplit(activeRot).second;
0578         rot = DDRotation(DDName(rotstr, rotns));
0579       } else {
0580         rot = DDRotation();
0581       }
0582       DDTranslation tran(0.0, -0.5 * backplaneThick[k], 0.0);  // from the definition of the wafer local axes
0583       cpv.position(active, wafer, 1, tran, rot);               // inactive backplane
0584       LogDebug("TIDGeom") << "DDTIDModuleAlgo test: " << active.name() << " number 1 positioned in " << wafer.name()
0585                           << " at " << tran << " with " << rot;
0586 
0587       //Pitch Adapter
0588       matter = DDMaterial(DDName(DDSplit(pitchMat).first, DDSplit(pitchMat).second));
0589       if (dlHybrid > dlTop) {
0590         dz = 0.5 * dlTop;
0591       } else {
0592         dz = 0.5 * dlBottom;
0593       }
0594       if (k == 0) {
0595         dx = dz;
0596         dy = 0.5 * pitchThick;
0597         dz = 0.5 * pitchHeight;
0598         solid = DDSolidFactory::box(DDName(DDSplit(pitchName[k]).first, DDSplit(pitchName[k]).second), dx, dy, dz);
0599         LogDebug("TIDGeom") << "DDTIDModuleAlgo test:\t" << solid.name() << " Box made of " << matter.ddname()
0600                             << " of dimensions"
0601                             << " " << dx << ", " << dy << ", " << dz;
0602       } else {
0603         h1 = 0.5 * pitchThick;
0604         bl1 = 0.5 * pitchHeight + 0.5 * dz * sin(detTilt);
0605         bl2 = 0.5 * pitchHeight - 0.5 * dz * sin(detTilt);
0606 
0607         dz -= 0.5 * pitchStereoTol;
0608         bl1 -= pitchStereoTol;
0609         bl2 -= pitchStereoTol;
0610 
0611         double thet = atan((bl1 - bl2) / (2. * dz));
0612         solid = DDSolidFactory::trap(DDName(DDSplit(pitchName[k]).first, DDSplit(pitchName[k]).second),
0613                                      dz,
0614                                      thet,
0615                                      0,
0616                                      h1,
0617                                      bl1,
0618                                      bl1,
0619                                      0,
0620                                      h1,
0621                                      bl2,
0622                                      bl2,
0623                                      0);
0624         LogDebug("TIDGeom") << "DDTIDModuleAlgo test:\t" << solid.name() << " Trap made of " << matter.ddname()
0625                             << " of "
0626                             << "dimensions " << dz << ", " << thet / CLHEP::deg << ", 0, " << h1 << ", " << bl1 << ", "
0627                             << bl1 << ", 0, " << h1 << ", " << bl2 << ", " << bl2 << ", 0";
0628       }
0629       DDLogicalPart pa(solid.ddname(), matter, solid);
0630     }
0631   }
0632   LogDebug("TIDGeom") << "<<== End of DDTIDModuleAlgo construction ...";
0633 }
0634 
0635 DEFINE_EDM_PLUGIN(DDAlgorithmFactory, DDTIDModuleAlgo, "track:DDTIDModuleAlgo");