CMS 3D CMS Logo

DDHCalEndcapAlgo.cc

Go to the documentation of this file.
00001 
00002 // File: DDHCalEndcapAlgo.cc
00003 //   adapted from CCal(G4)HcalEndcap.cc
00004 // Description: Geometry factory class for Hcal Endcap
00006 
00007 #include <cmath>
00008 #include <algorithm>
00009 
00010 namespace std{} using namespace std;
00011 #include "FWCore/MessageLogger/interface/MessageLogger.h"
00012 #include "DetectorDescription/Base/interface/DDutils.h"
00013 #include "DetectorDescription/Core/interface/DDPosPart.h"
00014 #include "DetectorDescription/Core/interface/DDLogicalPart.h"
00015 #include "DetectorDescription/Core/interface/DDSolid.h"
00016 #include "DetectorDescription/Core/interface/DDMaterial.h"
00017 #include "DetectorDescription/Core/interface/DDCurrentNamespace.h"
00018 #include "DetectorDescription/Core/interface/DDSplit.h"
00019 #include "Geometry/HcalAlgo/interface/DDHCalEndcapAlgo.h"
00020 #include "CLHEP/Units/PhysicalConstants.h"
00021 #include "CLHEP/Units/SystemOfUnits.h"
00022 
00023 DDHCalEndcapAlgo::DDHCalEndcapAlgo():
00024   modMat(0),modType(0),sectionModule(0),layerN(0),layerN0(0),layerN1(0),
00025   layerN2(0),layerN3(0),layerN4(0),layerN5(0),thick(0),trimLeft(0),
00026   trimRight(0),zminBlock(0),zmaxBlock(0),rinBlock1(0),routBlock1(0),
00027   rinBlock2(0),routBlock2(0),layerType(0),layerT(0),scintT(0) {
00028   LogDebug("HCalGeom") << "DDHCalEndcapAlgo info: Creating an instance";
00029 }
00030 
00031 DDHCalEndcapAlgo::~DDHCalEndcapAlgo() {}
00032 
00033 int DDHCalEndcapAlgo::getLayer(unsigned int i, unsigned int j) const {
00034 
00035   switch (i) {
00036   case 0: 
00037     return layerN0[j];
00038     break;
00039 
00040   case 1: 
00041     return layerN1[j];
00042     break;
00043 
00044   case 2: 
00045     return layerN2[j];
00046     break;
00047 
00048   case 3: 
00049     return layerN3[j];
00050     break;
00051 
00052   case 4: 
00053     return layerN4[j];
00054     break;
00055 
00056   case 5: 
00057     return layerN5[j];
00058     break;
00059 
00060   default:
00061     return 0;
00062   }
00063 }
00064 
00065 double DDHCalEndcapAlgo::getTrim(unsigned int i, unsigned int j) const {
00066  
00067  if (j == 0)
00068     return trimLeft[i];
00069   else
00070     return trimRight[j];
00071 }
00072 
00073 void DDHCalEndcapAlgo::initialize(const DDNumericArguments & nArgs,
00074                                   const DDVectorArguments & vArgs,
00075                                   const DDMapArguments & ,
00076                                   const DDStringArguments & sArgs,
00077                                   const DDStringVectorArguments & vsArgs) {
00078 
00079   int i,j;
00080   genMaterial   = sArgs["MaterialName"];
00081   rotation      = sArgs["Rotation"];
00082   nsectors      = int (nArgs["Sector"]);
00083   nsectortot    = int (nArgs["SectorTot"]);
00084   nEndcap       = int (nArgs["Endcap"]);
00085   rotHalf       = sArgs["RotHalf"];
00086   rotns         = sArgs["RotNameSpace"];
00087   zShift        = nArgs["ZShift"];
00088 
00089   zFront        = nArgs["ZFront"];
00090   zEnd          = nArgs["ZEnd"];
00091   ziNose        = nArgs["ZiNose"];
00092   ziL0Nose      = nArgs["ZiL0Nose"];
00093   ziBody        = nArgs["ZiBody"];
00094   ziL0Body      = nArgs["ZiL0Body"];
00095   z0Beam        = nArgs["Z0Beam"];
00096   ziDip         = nArgs["ZiDip"];
00097   dzStep        = nArgs["DzStep"];
00098   zShiftHac2    = nArgs["ZShiftHac2"];
00099   double gap    = nArgs["Gap"];
00100   double z1     = nArgs["Z1"];
00101   double r1     = nArgs["R1"];
00102   rout          = nArgs["Rout"];
00103   heboxDepth    = nArgs["HEboxDepth"];
00104   drEnd         = nArgs["DrEnd"];
00105   double etamin = nArgs["Etamin"];
00106   angBot        = nArgs["AngBot"];
00107   angGap        = nArgs["AngGap"];
00108 
00109   LogDebug("HCalGeom") << "DDHCalEndcapAlgo debug: General material " 
00110                        << genMaterial << "\tSectors "  << nsectors << ",  " 
00111                        << nsectortot << "\tEndcaps " << nEndcap  
00112                        << "\tRotation matrix for half " << rotns 
00113                        << ":" << rotHalf << "\n\tzFront " << zFront << " zEnd "
00114                        << zEnd << " ziNose " << ziNose << " ziL0Nose " 
00115                        << ziL0Nose << " ziBody " << ziBody  << " ziL0Body " 
00116                        << ziL0Body << " z0Beam " << z0Beam << " ziDip " 
00117                        << ziDip << " dzStep " << dzStep << " Gap " << gap 
00118                        << " z1 " << z1 << "\n\tr1 " << r1 << " rout " << rout
00119                        << " HeboxDepth " << heboxDepth << " drEnd " << drEnd 
00120                        << "\tetamin " << etamin << " Bottom angle " << angBot
00121                        << " Gap angle " << angGap << " Z-Shift " << zShift
00122                        << " " << zShiftHac2;
00123 
00124   //Derived quantities
00125   angTop   = 2.0 * atan (exp(-etamin));
00126   slope    = tan(angGap);
00127   z1Beam   = z1 - r1/slope;
00128   ziKink   = z1Beam + rout/slope;
00129   riKink   = ziKink*tan(angBot);
00130   riDip    = ziDip*tan(angBot);
00131   roDip    = rout - heboxDepth;
00132   dzShift  = (z1Beam - z0Beam) - gap/sin(angGap);
00133   LogDebug("HCalGeom") << "DDHCalEndcapAlgo debug: angTop " << angTop/deg 
00134                        <<"\tSlope " << slope << "\tDzShift " << dzShift
00135                        << "\n\tz1Beam " << z1Beam << "\tziKink" << ziKink
00136                        << "\triKink " << riKink << "\triDip " << riDip 
00137                        << "\n\troDip " << roDip << "\tRotation " << rotation;
00138 
00140   //Modules
00141   absMat        = sArgs["AbsMat"];
00142   modules       = int(nArgs["Modules"]);
00143   LogDebug("HCalGeom") << "DDHCalEndcapAlgo debug: Number of modules " 
00144                        << modules << " and absorber material " << absMat;
00145 
00146   modName       = vsArgs["ModuleName"];
00147   modMat        = vsArgs["ModuleMat"];
00148   modType       = dbl_to_int(vArgs["ModuleType"]);
00149   sectionModule = dbl_to_int(vArgs["SectionModule"]);
00150   thick         = vArgs["ModuleThick"];
00151   trimLeft      = vArgs["TrimLeft"]; 
00152   trimRight     = vArgs["TrimRight"]; 
00153   eModule       = dbl_to_int(vArgs["EquipModule"]);
00154   layerN        = dbl_to_int(vArgs["LayerN"]);
00155   layerN0       = dbl_to_int(vArgs["LayerN0"]);
00156   layerN1       = dbl_to_int(vArgs["LayerN1"]);
00157   layerN2       = dbl_to_int(vArgs["LayerN2"]);
00158   layerN3       = dbl_to_int(vArgs["LayerN3"]);
00159   layerN4       = dbl_to_int(vArgs["LayerN4"]);
00160   layerN5       = dbl_to_int(vArgs["LayerN5"]);
00161   for (i = 0; i < modules; i++) {
00162     LogDebug("HCalGeom") << "DDHCalEndcapAlgo debug: " << modName[i] <<" type "
00163                          << modType[i] << " Sections " << sectionModule[i] 
00164                          << " thickness of absorber/air " << thick[i] 
00165                          << " trim " << trimLeft[i] << ", " << trimRight[i] 
00166                          << " equip module " << eModule[i] << " with "
00167                          << layerN[i] << " layers";
00168     if (i == 0) {
00169       for (j = 0; j < layerN[i]; j++) {
00170         LogDebug("HCalGeom") << "\t " << layerN0[j] << "/" << layerN0[j+1];
00171       }
00172     } else if (i == 1) {
00173       for (j = 0; j < layerN[i]; j++) {
00174         LogDebug("HCalGeom") << "\t " << layerN1[j] << "/" << layerN1[j+1];
00175       }
00176     } else if (i == 2) {
00177       for (j = 0; j < layerN[i]; j++) {
00178         LogDebug("HCalGeom") << "\t " << layerN2[j];
00179       }
00180     } else if (i == 3) {
00181       for (j = 0; j < layerN[i]; j++) {
00182         LogDebug("HCalGeom") << "\t " << layerN3[j];
00183       }
00184     } else if (i == 4) {
00185       for (j = 0; j < layerN[i]; j++) {
00186         LogDebug("HCalGeom") << "\t " << layerN4[j];
00187       }
00188     } else if (i == 5) {
00189       for (j = 0; j < layerN[i]; j++) {
00190         LogDebug("HCalGeom") << "\t " << layerN5[j];
00191       }
00192     }
00193   }
00194   
00196   //Layers
00197   phiSections = int(nArgs["PhiSections"]);
00198   phiName     = vsArgs["PhiName"];
00199   layers      = int(nArgs["Layers"]);
00200   layerName   = vsArgs["LayerName"];
00201   layerType   = dbl_to_int(vArgs["LayerType"]);
00202   layerT      = vArgs["LayerT"];
00203   scintT      = vArgs["ScintT"];
00204   scintMat    = sArgs["ScintMat"];
00205   plastMat    = sArgs["PlastMat"];
00206   rotmat      = sArgs["RotMat"];
00207   LogDebug("HCalGeom") << "DDHCalEndcapAlgo debug: Phi Sections " 
00208                        << phiSections;
00209   for (i = 0; i < phiSections; i++) 
00210     LogDebug("HCalGeom") << "\tName[" << i << "] : " << phiName[i];
00211   LogDebug("HCalGeom") << "\tPlastic: " << plastMat << "\tScintillator: "
00212                        << scintMat << "\tRotation matrix " << rotns << ":" 
00213                        << rotmat << "\n\tNumber of layers " << layers;
00214   for (i = 0; i < layers; i++) {
00215     LogDebug("HCalGeom") << "\t" << layerName[i] << "\tType " << layerType[i]
00216                          << "\tThickness " << layerT[i] << "\tScint.Thick " 
00217                          << scintT[i];
00218   }
00219 
00221   // Derive bounding of the modules
00222   int module = 0;
00223   // Layer 0 (Nose)
00224   if (modules > 0) {
00225     zminBlock.push_back(ziL0Nose);
00226     zmaxBlock.push_back(zminBlock[module] + layerT[0] + 0.5*dzStep);
00227     rinBlock1.push_back(zminBlock[module] * tan(angTop));
00228     rinBlock2.push_back(zmaxBlock[module] * tan(angTop));
00229     routBlock1.push_back((zminBlock[module] - z1Beam) * slope);
00230     routBlock2.push_back((zmaxBlock[module] - z1Beam) * slope);
00231     module++;
00232   }
00233 
00234   // Layer 0 (Body)
00235   if (modules > 1) {
00236     zminBlock.push_back(ziL0Body);
00237     zmaxBlock.push_back(zminBlock[module] + layerT[0] + 0.5*dzStep);
00238     rinBlock1.push_back(zminBlock[module] * tan(angBot));
00239     rinBlock2.push_back(zmaxBlock[module] * tan(angBot));
00240     routBlock1.push_back(zminBlock[module] * tan(angTop));
00241     routBlock2.push_back(zmaxBlock[module] * tan(angTop));
00242     module++;
00243   }
00244 
00245   // Hac1
00246   if (modules > 2) {
00247     zminBlock.push_back(ziNose);
00248     zmaxBlock.push_back(ziBody);
00249     rinBlock1.push_back(zminBlock[module] * tan(angTop));
00250     rinBlock2.push_back(zmaxBlock[module] * tan(angTop));
00251     routBlock1.push_back((zminBlock[module] - z1Beam) * slope);
00252     routBlock2.push_back((zmaxBlock[module] - z1Beam) * slope);
00253     module++;
00254   }
00255 
00256   // Hac2
00257   if (modules > 3) {
00258     zminBlock.push_back(ziBody);
00259     zmaxBlock.push_back(zminBlock[module] + layerN[3]*dzStep);
00260     rinBlock1.push_back(zminBlock[module] * tan(angBot));
00261     rinBlock2.push_back(zmaxBlock[module] * tan(angBot));
00262     routBlock1.push_back((zmaxBlock[module-1] - z1Beam) * slope);
00263     routBlock2.push_back(rout);
00264     module++;
00265   }
00266 
00267   // Hac3
00268   if (modules > 4) {
00269     zminBlock.push_back(zmaxBlock[module-1]);
00270     zmaxBlock.push_back(zminBlock[module] + layerN[4]*dzStep);
00271     rinBlock1.push_back(zminBlock[module] * tan(angBot));
00272     rinBlock2.push_back(zmaxBlock[module] * tan(angBot));
00273     routBlock1.push_back(rout);
00274     routBlock2.push_back(rout);
00275     module++;
00276   }
00277 
00278   // Hac4
00279   if (modules > 5) {
00280     zminBlock.push_back(zmaxBlock[module-1]);
00281     zmaxBlock.push_back(zminBlock[module] + layerN[5]*dzStep);
00282     rinBlock1.push_back(zminBlock[module] * tan(angBot));
00283     rinBlock2.push_back(zmaxBlock[module] * tan(angBot));
00284     routBlock1.push_back(rout);
00285     routBlock2.push_back(roDip);
00286     module++;
00287   }
00288 
00289   for (i = 0; i < module; i++)
00290     LogDebug("HCalGeom") << "DDHCalEndcapAlgo debug: Module " << i 
00291                          << "\tZ/Rin/Rout " << zminBlock[i] << ", " 
00292                          << zmaxBlock[i] << "/ " << rinBlock1[i] << ", " 
00293                          << rinBlock2[i] << "/ " << routBlock1[i] << ", " 
00294                          << routBlock2[i];
00295 
00296   idName      = sArgs["MotherName"];
00297   idNameSpace = DDCurrentNamespace::ns();
00298   idOffset = int (nArgs["IdOffset"]); 
00299   DDName parentName = parent().name(); 
00300   LogDebug("HCalGeom") << "DDHCalEndcapAlgo debug: Parent " << parentName 
00301                        << " idName " << idName << " NameSpace " << idNameSpace
00302                        << " Offset " << idOffset;
00303 
00304   tolPos      = nArgs["TolPos"];
00305   tolAbs      = nArgs["TolAbs"];
00306   LogDebug("HCalGeom") << "DDHCalEndcapAlgo debug: Tolerances - Positioning "
00307                        << tolPos << " Absorber " << tolAbs;
00308 }
00309 
00311 // DDHCalEndcapAlgo methods...
00313 
00314 void DDHCalEndcapAlgo::execute() {
00315   
00316   LogDebug("HCalGeom") << "==>> Constructing DDHCalEndcapAlgo...";
00317   constructGeneralVolume();
00318   LogDebug("HCalGeom") << "<<== End of DDHCalEndcapAlgo construction ...";
00319 }
00320 
00321 //----------------------start here for DDD work!!! ---------------
00322 
00323 void DDHCalEndcapAlgo::constructGeneralVolume() {
00324   
00325   LogDebug("HCalGeom") << "DDHCalEndcapAlgo test: General volume...";
00326   bool proto = true;
00327   for (int i=0; i<3; i++) 
00328     if (equipModule(i) > 0) proto = false;
00329 
00330   DDRotation    rot;
00331   if (DDSplit(getRotation()).first == "NULL") rot = DDRotation();
00332   else rot = DDRotation(DDName(DDSplit(getRotation()).first,DDSplit(getRotation()).second));
00333   LogDebug("HCalGeom") << " First " << DDSplit(getRotation()).first
00334                        << " Second " << DDSplit(getRotation()).second 
00335                        << " Rotation " << rot;
00336   DDTranslation r0(0,0,getZShift());
00337   double alpha = pi/getNsectors();
00338   double dphi  = getNsectortot()*twopi/getNsectors();
00339 
00341   //vertical walls are allowed in SolidPolyhedra
00342   double delz = 0;
00343 
00344   vector<double> pgonZ, pgonRmin, pgonRmax;
00345   if (proto) {
00346     double zf = getZiBody() + getZShiftHac2();
00347     pgonZ.push_back(zf - getDzShift()); 
00348     pgonRmin.push_back(zf * tan(getAngBot())); 
00349     pgonRmax.push_back((zf - getZ1Beam())*getSlope()); 
00350   } else {
00351     pgonZ.push_back(getZFront()   - getDzShift()); 
00352     pgonRmin.push_back(getZFront()   * tan(getAngTop())); 
00353     pgonRmax.push_back((getZFront()   - getZ1Beam())*getSlope()); 
00354     pgonZ.push_back(getZiL0Body() - getDzShift()); 
00355     pgonRmin.push_back(getZiL0Body() * tan(getAngTop())); 
00356     pgonRmax.push_back((getZiL0Body() - getZ1Beam())*getSlope()); 
00357     pgonZ.push_back(getZiL0Body() - getDzShift()); 
00358     pgonRmin.push_back(getZiL0Body() * tan(getAngBot())); 
00359     pgonRmax.push_back((getZiL0Body() - getZ1Beam())*getSlope()); 
00360   }
00361   pgonZ.push_back(getZiKink()   - getDzShift()); 
00362   pgonRmin.push_back(getRinKink()); 
00363   pgonRmax.push_back(getRout()); 
00364   pgonZ.push_back(getZiDip()    - getDzShift()); 
00365   pgonRmin.push_back(getRinDip()); 
00366   pgonRmax.push_back(getRout()); 
00367   pgonZ.push_back(getZiDip()    - getDzShift() + delz); 
00368   pgonRmin.push_back(getRinDip()); 
00369   pgonRmax.push_back(getRoutDip()); 
00370   pgonZ.push_back(getZEnd()     - getDzShift()); 
00371   pgonRmin.push_back(getZEnd() * tan(getAngBot())); 
00372   pgonRmax.push_back(getRoutDip()); 
00373   pgonZ.push_back(getZEnd()); 
00374   pgonRmin.push_back(getZEnd() * tan(getAngBot())); 
00375   pgonRmax.push_back(getRoutDip()); 
00376 
00377   string name("Null");
00378   unsigned int i=0;
00379   DDSolid solid;
00380   solid = DDSolidFactory::polyhedra(DDName(idName, idNameSpace),
00381                                     getNsectortot(), -alpha, dphi, pgonZ, 
00382                                     pgonRmin, pgonRmax);
00383   LogDebug("HCalGeom") << "DDHCalEndcapAlgo test: " 
00384                        << DDName(idName, idNameSpace) << " Polyhedra made of "
00385                        << getGenMat() << " with " << getNsectortot() 
00386                        << " sectors from " << -alpha/deg << " to " 
00387                        << (-alpha+dphi)/deg << " and with " << pgonZ.size() 
00388                        << " sections";
00389   for (i = 0; i <pgonZ.size(); i++) 
00390     LogDebug("HCalGeom") << "\t\tZ = " << pgonZ[i] << "\tRmin = " <<pgonRmin[i]
00391                          << "\tRmax = " << pgonRmax[i];
00392 
00393   DDName matname(DDSplit(getGenMat()).first, DDSplit(getGenMat()).second); 
00394   DDMaterial matter(matname);
00395   DDLogicalPart genlogic(DDName(idName, idNameSpace), matter, solid);
00396 
00397   DDName parentName = parent().name(); 
00398   DDpos(DDName(idName, idNameSpace), parentName, 1, r0, rot);
00399   LogDebug("HCalGeom") << "DDHCalEndcapAlgo test: " 
00400                        << DDName(idName, idNameSpace) << " number 1 positioned"
00401                        << " in " << parentName << " at " << r0 << " with " 
00402                        << rot;
00403   if (getEndcaps() != 1) {
00404     rot = DDRotation(DDName(rotHalf,rotns));
00405     DDpos (DDName(idName, idNameSpace), parentName, 2, r0, rot);
00406     LogDebug("HCalGeom") << "DDHCalEndcapAlgo test: " 
00407                          << DDName(idName, idNameSpace) << " number 2 "
00408                          << "positioned in " << parentName  << " at " << r0
00409                          << " with " << rot;
00410   }
00411 
00412   //Forward half
00413   name  = idName + "Front";
00414   vector<double> pgonZMod, pgonRminMod, pgonRmaxMod;
00415   for (i=0; i < (pgonZ.size()-1); i++) {
00416     pgonZMod.push_back(pgonZ[i] + getDzShift()); 
00417     pgonRminMod.push_back(pgonRmin[i]); 
00418     pgonRmaxMod.push_back(pgonRmax[i]); 
00419   }
00420   solid = DDSolidFactory::polyhedra(DDName(name, idNameSpace),
00421                                     getNsectortot(), -alpha, dphi, pgonZMod,
00422                                     pgonRminMod, pgonRmaxMod);
00423   LogDebug("HCalGeom") << "DDHCalEndcapAlgo test: " << DDName(name,idNameSpace)
00424                        << " Polyhedra made of " << getGenMat() << " with "
00425                        << getNsectortot() << " sectors from " << -alpha/deg 
00426                        << " to " << (-alpha+dphi)/deg << " and with "
00427                        << pgonZMod.size() << " sections ";
00428   for (i = 0; i < pgonZMod.size(); i++) 
00429     LogDebug("HCalGeom") << "\t\tZ = " << pgonZMod[i] << "\tRmin = " 
00430                          << pgonRminMod[i] << "\tRmax = " << pgonRmaxMod[i];
00431   DDLogicalPart genlogich(DDName(name, idNameSpace), matter, solid);
00432 
00433   DDpos(genlogich, genlogic, 1, DDTranslation(0.0, 0.0, -getDzShift()),
00434         DDRotation());
00435   LogDebug("HCalGeom") << "DDHCalEndcapAlgo test: " << genlogich.name() 
00436                        << " number 1 positioned in " << genlogic.name() 
00437                        << " at (0,0," << -getDzShift() << ") with no rotation";
00438   
00439   //Construct sector (from -alpha to +alpha)
00440   name  = idName + "Module";
00441   solid =   DDSolidFactory::polyhedra(DDName(name, idNameSpace),
00442                                       1, -alpha, 2*alpha, pgonZMod,
00443                                       pgonRminMod, pgonRmaxMod);
00444   LogDebug("HCalGeom") << "DDHCalEndcapAlgo test: " << DDName(name,idNameSpace)
00445                        << " Polyhedra made of " << getGenMat() 
00446                        <<" with 1 sector from " << -alpha/deg << " to " 
00447                        << alpha/deg << " and with " << pgonZMod.size() 
00448                        << " sections";
00449   for (i = 0; i < pgonZMod.size(); i++) 
00450     LogDebug("HCalGeom") << "\t\tZ = " << pgonZMod[i] << "\tRmin = " 
00451                          << pgonRminMod[i] << "\tRmax = " << pgonRmaxMod[i];
00452 
00453   DDLogicalPart seclogic(DDName(name, idNameSpace), matter, solid);
00454   
00455   for (int ii=0; ii<getNsectortot(); ii++) {
00456     double phi    = ii*2*alpha;
00457     double phideg = phi/deg;
00458     
00459     DDRotation rotation;
00460     string rotstr("NULL");
00461     if (phideg != 0) {
00462       rotstr = "R"; 
00463       if (phideg < 100) rotstr = "R0"; 
00464       rotstr = rotstr + dbl_to_string(phideg);
00465       rotation = DDRotation(DDName(rotstr, rotns)); 
00466       if (!rotation) {
00467         LogDebug("HCalGeom") << "DDHCalEndcapAlgo test: Creating a new "
00468                              << "rotation " << rotstr << "\t" << 90 << "," 
00469                              << phideg << ","  << 90 << "," << (phideg+90)
00470                              << ", 0, 0";
00471         rotation = DDrot(DDName(rotstr, rotns), 90*deg, phideg*deg, 
00472                          90*deg, (90+phideg)*deg, 0*deg,  0*deg);
00473       } //if !rotation
00474     } //if phideg!=0
00475   
00476     DDpos (seclogic, genlogich, ii+1, DDTranslation(0.0, 0.0, 0.0), rotation);
00477     LogDebug("HCalGeom") << "DDHCalEndcapAlgo test: " << seclogic.name() 
00478                          << " number " << ii+1 << " positioned in " 
00479                          << genlogich.name() << " at (0,0,0) with " <<rotation;
00480   }
00481   
00482   //Construct the things inside the sector
00483   constructInsideSector(seclogic);
00484 
00485   //Backward half
00486   name  = idName + "Back";
00487   vector<double> pgonZBack, pgonRminBack, pgonRmaxBack;
00488   pgonZBack.push_back(getZEnd() - getDzShift()); 
00489   pgonRminBack.push_back(pgonZBack[0]*tan(getAngBot()) + getDrEnd()); 
00490   pgonRmaxBack.push_back(getRoutDip()); 
00491   pgonZBack.push_back(getZEnd()); 
00492   pgonRminBack.push_back(pgonZBack[1]*tan(getAngBot()) + getDrEnd()); 
00493   pgonRmaxBack.push_back(getRoutDip()); 
00494   solid = DDSolidFactory::polyhedra(DDName(name, idNameSpace),
00495                                     getNsectortot(), -alpha, dphi, pgonZBack,
00496                                     pgonRminBack, pgonRmaxBack);
00497   LogDebug("HCalGeom") << "DDHCalEndcapAlgo test: " << DDName(name,idNameSpace)
00498                        << " Polyhedra made of " << getAbsMat() << " with " 
00499                        << getNsectortot() << " sectors from " << -alpha/deg 
00500                        << " to " << (-alpha+dphi)/deg << " and with " 
00501                        << pgonZBack.size()      << " sections";
00502   for (i = 0; i < pgonZBack.size(); i++) 
00503     LogDebug("HCalGeom") << "\t\tZ = " << pgonZBack[i] << "\tRmin = " 
00504                          << pgonRminBack[i] << "\tRmax = " << pgonRmaxBack[i];
00505   DDName absMatname(DDSplit(getAbsMat()).first, DDSplit(getAbsMat()).second); 
00506   DDMaterial absMatter(absMatname);
00507   DDLogicalPart glog(DDName(name, idNameSpace), absMatter, solid);
00508 
00509   DDpos(glog, genlogic, 1, DDTranslation(0.0, 0.0, 0.0), DDRotation());
00510   LogDebug("HCalGeom") << "DDHCalEndcapAlgo test: " << glog.name() 
00511                        << " number 1 positioned in "  << genlogic.name() 
00512                        << " at (0,0,0) with no rotation";
00513 }
00514 
00515 
00516 void DDHCalEndcapAlgo::constructInsideSector(DDLogicalPart sector) {
00517   
00518   LogDebug("HCalGeom") << "DDHCalEndcapAlgo test: Modules (" << getModules()
00519                        << ") ...";
00520   double alpha = pi/getNsectors();
00521 
00522   for (int i = 0; i < getModules(); i++) {
00523     string  name   = idName + getModName(i);
00524     DDName matname(DDSplit(getModMat(i)).first, DDSplit(getModMat(i)).second); 
00525     DDMaterial matter(matname);
00526     
00527     if (equipModule(i)>0) {
00528       int nsec = getSectionModule(i);
00529 
00531       //vertical walls are allowed in SolidPolyhedra
00532       double deltaz = 0;
00533     
00534       vector<double> pgonZ, pgonRmin, pgonRmax;
00535       if (nsec == 3) {
00536         double zf = getZminBlock(i) + getZShiftHac2();
00537         pgonZ.push_back(zf);
00538         pgonRmin.push_back(zf*tan(getAngBot())); 
00539         pgonRmax.push_back((zf-getZ1Beam())*getSlope());
00540         pgonZ.push_back(getZiKink());  
00541         pgonRmin.push_back(getRinKink()); 
00542         pgonRmax.push_back(getRout());
00543       } else {
00544         pgonZ.push_back(getZminBlock(i));
00545         pgonRmin.push_back(getRinBlock1(i)); 
00546         pgonRmax.push_back(getRoutBlock1(i));
00547       }
00548       if (nsec == 4) {
00549         pgonZ.push_back(getZiDip());
00550         pgonRmin.push_back(getRinDip());
00551         pgonRmax.push_back(getRout());
00552         pgonZ.push_back(pgonZ[1] + deltaz);
00553         pgonRmin.push_back(pgonRmin[1]); 
00554         pgonRmax.push_back(getRoutDip());
00555       }
00556       pgonZ.push_back(getZmaxBlock(i));
00557       pgonRmin.push_back(getRinBlock2(i)); 
00558       pgonRmax.push_back(getRoutBlock2(i));
00559 
00560       //Solid & volume
00561       DDSolid solid;
00562       solid = DDSolidFactory::polyhedra(DDName(name, idNameSpace), 
00563                                         1, -alpha, 2*alpha,
00564                                         pgonZ, pgonRmin, pgonRmax);
00565       LogDebug("HCalGeom") << "DDHCalEndcapAlgo test: " 
00566                            << DDName(name,idNameSpace) << " Polyhedra made of "
00567                            << getModMat(i) << " with 1 sector from "
00568                            << -alpha/deg << " to " << alpha/deg << " and with "
00569                            << nsec << " sections";
00570       for (unsigned int k=0; k<pgonZ.size(); k++)
00571         LogDebug("HCalGeom") << "\t\tZ = " << pgonZ[k] << "\tRmin = "
00572                              << pgonRmin[k] << "\tRmax = " << pgonRmax[k];
00573     
00574       DDLogicalPart glog(DDName(name, idNameSpace), matter, solid);
00575 
00576       DDpos (glog, sector, i+1, DDTranslation(0.0, 0.0, 0.0), DDRotation());
00577       LogDebug("HCalGeom") << "DDHCalEndcapAlgo test: " << glog.name() 
00578                            << " number " << i+1 << " positioned in " 
00579                            << sector.name() << " at (0,0,0) with no rotation";
00580       
00581       if (getModType(i) == 0) 
00582         constructInsideModule0 (glog, i);
00583       else
00584         constructInsideModule  (glog, i);
00585     }
00586   }
00587   
00588 }
00589 
00590 void DDHCalEndcapAlgo::parameterLayer0(int mod, int layer, int iphi, 
00591                                        double& yh, double& bl, double& tl, 
00592                                        double& alp, double& xpos, double& ypos,
00593                                        double& zpos) {
00594 
00595   //Given module and layer number compute parameters of trapezoid
00596   //and positioning parameters
00597   double alpha = pi/getNsectors();
00598   LogDebug("HCalGeom") << "Input " << iphi << " " << layer << " " << iphi
00599                        << " Alpha " << alpha/deg;
00600 
00601   double zi, zo;
00602   if (iphi == 0) {
00603     zi = getZminBlock(mod);
00604     zo = zi + getLayerT(layer);
00605   } else {
00606     zo = getZmaxBlock(mod);
00607     zi = zo - getLayerT(layer);
00608   }
00609   double rin, rout;
00610   if (mod == 0) {
00611     rin  = zo * tan(getAngTop());
00612     rout = (zi - getZ1Beam()) * getSlope();
00613   } else {
00614     rin  = zo * tan(getAngBot());
00615     rout = zi * tan(getAngTop());
00616   }
00617   yh   = 0.5 * (rout - rin);
00618   bl   = 0.5 * rin * tan (alpha);
00619   tl   = 0.5 * rout * tan(alpha);
00620   xpos = 0.5 * (rin + rout);
00621   ypos = 0.5 * (bl + tl);
00622   zpos = 0.5 * (zi + zo);
00623   yh  -= getTrim(mod,iphi);
00624   bl  -= getTrim(mod,iphi);
00625   tl  -= getTrim(mod,iphi);
00626   alp  = 0.5 * alpha;
00627   if (iphi == 0) {
00628     ypos  = -ypos;
00629   } else {
00630     alp  = -alp;
00631   }
00632   LogDebug("HCalGeom") << "Output Dimensions " << yh << " " << bl << " "
00633                        << tl << " " << alp/deg << " Position " << xpos << " " 
00634                        << ypos << " " << zpos;
00635 }
00636 
00637 
00638 void DDHCalEndcapAlgo::parameterLayer(int iphi, double rinF, double routF,
00639                                       double rinB, double routB, double zi,
00640                                       double zo, double& yh1, double& bl1,
00641                                       double& tl1, double& yh2, double& bl2,
00642                                       double& tl2, double& alp, double& theta,
00643                                       double& phi, double& xpos, double& ypos,
00644                                       double& zpos) {
00645 
00646   //Given rin, rout compute parameters of the trapezoid and 
00647   //position of the trapezoid for a standrd layer
00648   double alpha = pi/getNsectors();
00649   LogDebug("HCalGeom") << "Input " << iphi << " Front " << rinF << " " << routF
00650                        << " " << zi << " Back " << rinB << " " << routB << " "
00651                        << zo << " Alpha " << alpha/deg;
00652 
00653   yh1 = 0.5 * (routF - rinF);
00654   bl1 = 0.5 * rinF  * tan(alpha);
00655   tl1 = 0.5 * routF * tan(alpha);
00656   yh2 = 0.5 * (routB - rinB);
00657   bl2 = 0.5 * rinB  * tan(alpha);
00658   tl2 = 0.5 * routB * tan(alpha);
00659   double dx  = 0.25* (bl2+tl2-bl1-tl1);
00660   double dy  = 0.5 * (rinB+routB-rinF-routF);
00661   xpos = 0.25*(rinB+routB+rinF+routF);
00662   ypos = 0.25*(bl2+tl2+bl1+tl1);
00663   zpos = 0.5*(zi+zo);
00664   alp  = 0.5 * alpha;
00665   ypos-= getTolPos();
00666   if (iphi == 0) {
00667     ypos  = -ypos;
00668   } else {
00669     alp  = -alp;
00670     dx   = -dx;
00671   }
00672   double r   = sqrt (dx*dx + dy*dy);
00673   theta= atan (r/(zo-zi));
00674   phi  = atan2 (dy, dx);
00675   LogDebug("HCalGeom") << "Output Dimensions " << yh1 << " " << bl1 << " "
00676                        << tl1 << " " << yh2 << " " << bl2 << " " << tl2
00677                        << " " << alp/deg << " " << theta/deg << " "
00678                        << phi/deg << " Position " << xpos << " " << ypos
00679                        << " " << zpos;
00680 }
00681 
00682 
00683 void DDHCalEndcapAlgo::constructInsideModule0(DDLogicalPart module, int mod) {
00684   
00685   LogDebug("HCalGeom") << "DDHCalEndcapAlgo test: \t\tInside module0 ..."<<mod;
00686 
00688   //Pointers to the Rotation Matrices and to the Materials
00689   string rotstr = getRotMat();
00690   DDRotation rot(DDName(rotstr, rotns));
00691   DDName matName(DDSplit(getAbsMat()).first, DDSplit(getAbsMat()).second);
00692   DDMaterial matabsorbr(matName);
00693   DDName plasName(DDSplit(getPlastMat()).first, DDSplit(getPlastMat()).second);
00694   DDMaterial matplastic(plasName);
00695 
00696   int     layer  = getLayer(mod,0);
00697   int     layer0 = getLayer(mod,1);
00698   string  name;
00699   double  xpos, ypos, zpos;
00700   DDSolid solid;
00701   DDLogicalPart glog, plog;
00702   for (int iphi = 0; iphi < getPhi(); iphi++) {
00703     double yh, bl, tl, alp;
00704     parameterLayer0(mod, layer, iphi, yh, bl, tl, alp, xpos, ypos, zpos);
00705     name = module.name().name()+getLayerName(layer)+getPhiName(iphi);
00706     solid = DDSolidFactory::trap(DDName(name, idNameSpace), 
00707                                  0.5*getLayerT(layer), 0, 0, yh,
00708                                  bl, tl, alp, yh, bl, tl, alp);
00709     LogDebug("HCalGeom") << "DDHCalEndcapAlgo test: " << solid.name() 
00710                          << " Trap made of " << getPlastMat() 
00711                          << " of dimensions " << 0.5*getLayerT(layer) 
00712                          << ", 0, 0, " << yh << ", " << bl << ", " << tl 
00713                          << ", " << alp/deg << ", " << yh << ", " << bl 
00714                          << ", " << tl << ", " << alp/deg;
00715     glog = DDLogicalPart(solid.ddname(), matplastic, solid);
00716 
00717     DDTranslation r1(xpos, ypos, zpos);
00718     DDpos(glog, module, idOffset+layer+1, r1, rot);
00719     LogDebug("HCalGeom") << "DDHCalEndcapAlgo test: " << glog.name() 
00720                          << " number " << idOffset+layer+1 << " positioned in "
00721                          << module.name() << " at " << r1 << " with " << rot;
00722     //Now construct the layer of scintillator inside this
00723     int copyNo = layer0*10 + getLayerType(layer);
00724     name = getModName(mod)+getLayerName(layer)+getPhiName(iphi);
00725     constructScintLayer (glog, getScintT(layer), yh, bl, tl, alp, name,copyNo);
00726   }
00727 
00728   //Now the absorber layer
00729   double zi = getZminBlock(mod) + getLayerT(layer);
00730   double zo = zi + 0.5*getDzStep();
00731   double rinF, routF, rinB, routB;
00732   if (mod == 0) {
00733     rinF  = zi * tan(getAngTop());
00734     routF =(zi - getZ1Beam()) * getSlope();
00735     rinB  = zo * tan(getAngTop());
00736     routB =(zo - getZ1Beam()) * getSlope();
00737   } else {
00738     rinF  = zi * tan(getAngBot());
00739     routF = zi * tan(getAngTop());
00740     rinB  = zo * tan(getAngBot());
00741     routB = zo * tan(getAngTop());
00742   }
00743   LogDebug("HCalGeom") << "DDHCalEndcapAlgo test: Module " << mod << " Front "
00744                        << zi << ", " << rinF << ", " << routF << " Back "
00745                        << zo << ", " << rinB << ", " << routB;
00746   double yh1, bl1, tl1, yh2, bl2, tl2, theta, phi, alp;
00747   parameterLayer(0, rinF, routF, rinB, routB, zi, zo, yh1, bl1, tl1, yh2, bl2, 
00748                  tl2, alp, theta, phi, xpos, ypos, zpos);
00749   double fact = getTolAbs();
00750   LogDebug("HCalGeom") << "DDHCalEndcapAlgo test: Trim " << fact << " Param "
00751                        << yh1 << ", " << bl1 << ", " << tl1 << ", " << yh2
00752                        << ", " << bl2 << ", " << tl2;
00753   bl1 -= fact;
00754   tl1 -= fact;
00755   bl2 -= fact;
00756   tl2 -= fact;
00757 
00758   name = module.name().name()+"Absorber";
00759   solid = DDSolidFactory::trap(DDName(name, idNameSpace), 
00760                                0.5*getThick(mod), theta, phi, yh1,
00761                                bl1, tl1, alp, yh2, bl2, tl2, alp);
00762   LogDebug("HCalGeom") << "DDHCalEndcapAlgo test: " << solid.name() 
00763                        << " Trap made of " << getAbsMat() << " of dimensions " 
00764                        << 0.5*getThick(mod) << ", " << theta/deg << ", " 
00765                        << phi/deg << ", " << yh1 << ", " << bl1 << ", " 
00766                        << tl1 << ", " << alp/deg << ", " << yh2 << ", " << bl2 
00767                        << ", " << tl2 << ", " << alp/deg;
00768   glog = DDLogicalPart(solid.ddname(), matabsorbr, solid);
00769 
00770   DDTranslation r2(xpos, ypos, zpos);
00771   DDpos(glog, module, 1, r2, rot);
00772   LogDebug("HCalGeom") << "DDHCalEndcapAlgo test: " << glog.name() 
00773                        << " number 1 positioned in " << module.name() << " at "
00774                        << r2 << " with " << rot;
00775 }
00776 
00777 
00778 void DDHCalEndcapAlgo::constructInsideModule(DDLogicalPart module, int mod) {
00779   
00780   LogDebug("HCalGeom") << "DDHCalEndcapAlgo test: \t\tInside module ..." <<mod;
00781 
00783   //Pointers to the Rotation Matrices and to the Materials
00784   string rotstr = getRotMat();
00785   DDRotation rot(DDName(rotstr, rotns));
00786   DDName matName(DDSplit(getGenMat()).first, DDSplit(getGenMat()).second);
00787   DDMaterial matter(matName);
00788   DDName plasName(DDSplit(getPlastMat()).first, DDSplit(getPlastMat()).second);
00789   DDMaterial matplastic(plasName);
00790 
00791   double  alpha = pi/getNsectors();
00792   double  zi    = getZminBlock(mod);
00793 
00794   for (int i = 0; i < getLayerN(mod); i++) {
00795     string name;
00796     DDSolid solid;
00797     DDLogicalPart glog, plog;
00798     int     layer  = getLayer(mod,i);
00799     double  zo     = zi + 0.5*getDzStep();
00800 
00801     for (int iphi = 0; iphi < getPhi(); iphi++) {
00802       double  ziAir = zo - getThick(mod);
00803       double  rinF, rinB;
00804       if (layer == 1) {
00805         rinF  = ziAir * tan(getAngTop());
00806         rinB  = zo    * tan(getAngTop());
00807       } else {
00808         rinF  = ziAir * tan(getAngBot());
00809         rinB  = zo    * tan(getAngBot());
00810       }
00811       double routF = (ziAir - getZ1Beam()) * getSlope();
00812       double routB = (zo    - getZ1Beam()) * getSlope();
00813       if (routF > getRoutBlock2(mod)) routF =  getRoutBlock2(mod);
00814       if (routB > getRoutBlock2(mod)) routB =  getRoutBlock2(mod);
00815       LogDebug("HCalGeom") << "DDHCalEndcapAlgo test: Layer " << i << " Phi "
00816                            << iphi << " Front " << ziAir << ", " << rinF
00817                            << ", " << routF << " Back " << zo << ", " << rinB
00818                            << ", " << routB;
00819       double yh1, bl1, tl1, yh2, bl2, tl2, theta, phi, alp;
00820       double xpos, ypos, zpos;
00821       parameterLayer(iphi, rinF, routF, rinB, routB, ziAir, zo, yh1, bl1, tl1, 
00822                      yh2, bl2, tl2, alp, theta, phi, xpos, ypos, zpos);
00823       
00824       name = module.name().name()+getLayerName(layer)+getPhiName(iphi)+"Air";
00825       solid = DDSolidFactory::trap(DDName(name, idNameSpace), 
00826                                    0.5*getThick(mod), theta, phi, yh1,
00827                                    bl1, tl1, alp, yh2, bl2, tl2, alp);
00828       LogDebug("HCalGeom") << "DDHCalEndcapAlgo test: " << solid.name() 
00829                            << " Trap made of " << getGenMat() 
00830                            << " of dimensions " << 0.5*getThick(mod) << ", " 
00831                            << theta/deg << ", " << phi/deg << ", " << yh1 
00832                            << ", " << bl1 << ", " << tl1 << ", " << alp/deg 
00833                            << ", " << yh2 << ", " << bl2 << ", " << tl2 << ", "
00834                            << alp/deg;
00835       glog = DDLogicalPart(solid.ddname(), matter, solid);
00836 
00837       DDTranslation r1(xpos, ypos, zpos);
00838       DDpos(glog, module, layer+1, r1, rot);
00839       LogDebug("HCalGeom") << "DDHCalEndcapAlgo test: " << glog.name() 
00840                            << " number " << layer+1 << " positioned in " 
00841                            << module.name() << " at " << r1 << " with " << rot;
00842 
00843       //Now the plastic with scintillators
00844       double yh = 0.5 * (routF - rinB) - getTrim(mod,iphi);
00845       double bl = 0.5 * rinB  * tan(alpha) - getTrim(mod,iphi);
00846       double tl = 0.5 * routF * tan(alpha) - getTrim(mod,iphi);
00847       name = module.name().name()+getLayerName(layer)+getPhiName(iphi);
00848       solid = DDSolidFactory::trap(DDName(name, idNameSpace), 
00849                                    0.5*getLayerT(layer), 0, 0, yh,
00850                                    bl, tl, alp, yh, bl, tl, alp);
00851       LogDebug("HCalGeom") << "DDHCalEndcapAlgo test: " << solid.name() 
00852                            << " Trap made of " << getPlastMat() 
00853                            << " of dimensions " << 0.5*getLayerT(layer) 
00854                            << ", 0, 0, " << yh << ", " << bl << ", " << tl
00855                            << ", " << alp/deg << ", " << yh << ", " << bl 
00856                            << ", " << tl << ", " << alp/deg;
00857       plog = DDLogicalPart(solid.ddname(), matplastic, solid);
00858 
00859       ypos = 0.5*(routF+rinB) - xpos;
00860       DDTranslation r2(0., ypos, 0.);
00861       DDpos(plog, glog, idOffset+layer+1, r2, DDRotation());
00862       LogDebug("HCalGeom") << "DDHCalEndcapAlgo test: " << plog.name() 
00863                            << " number " << idOffset+layer+1 
00864                            << " positioned in " << glog.name() << " at " << r2
00865                            << " with no rotation";
00866 
00867       //Constructin the scintillators inside
00868       int copyNo = layer*10 + getLayerType(layer);
00869       name = getModName(mod)+getLayerName(layer)+getPhiName(iphi);
00870       constructScintLayer (plog, getScintT(layer), yh,bl,tl, alp,name,copyNo);
00871       zo += 0.5*getDzStep();
00872     } // End of loop over phi indices
00873     zi = zo - 0.5*getDzStep();
00874   }   // End of loop on layers
00875 }
00876 
00877  
00878 void DDHCalEndcapAlgo::constructScintLayer(DDLogicalPart detector, double dz,
00879                                            double yh, double bl, double tl, 
00880                                            double alp, string nm, int id) {
00881 
00882   DDName matname(DDSplit(getScintMat()).first, DDSplit(getScintMat()).second);
00883   DDMaterial matter(matname);
00884   string name = idName+"Scintillator"+nm;
00885 
00886   DDSolid solid = DDSolidFactory::trap(DDName(name, idNameSpace), 0.5*dz, 0, 0,
00887                                        yh, bl, tl, alp, yh, bl, tl, alp);
00888   LogDebug("HCalGeom") << "DDHCalEndcapAlgo test: " << DDName(name,idNameSpace)
00889                        << " Trap made of " << getScintMat() <<" of dimensions "
00890                        << 0.5*dz << ", 0, 0, " << yh << ", "  << bl << ", " 
00891                        << tl << ", " << alp/deg << ", " << yh << ", " << bl 
00892                        << ", " << tl << ", " << alp/deg;
00893 
00894   DDLogicalPart glog(solid.ddname(), matter, solid); 
00895 
00896   DDpos(glog, detector, id, DDTranslation(0,0,0), DDRotation());
00897   LogDebug("HCalGeom") << "DDHCalEndcapAlgo test: " << glog.name() 
00898                        << " number " << id << " positioned in " 
00899                        << detector.name() << " at (0,0,0) with no rotation";
00900 
00901 }

Generated on Tue Jun 9 17:37:30 2009 for CMSSW by  doxygen 1.5.4