00001
00002
00003
00004
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/DDHCalBarrelAlgo.h"
00020 #include "CLHEP/Units/PhysicalConstants.h"
00021 #include "CLHEP/Units/SystemOfUnits.h"
00022
00023 DDHCalBarrelAlgo::DDHCalBarrelAlgo():
00024 theta(0),rmax(0),zoff(0),ttheta(0),layerId(0),layerLabel(0),layerMat(0),
00025 layerWidth(0),layerD1(0),layerD2(0),layerAlpha(0),layerT1(0),layerT2(0),
00026 layerAbsorb(0),layerGap(0),absorbName(0),absorbMat(0),absorbD(0),absorbT(0),
00027 midName(0),midMat(0),midW(0),midT(0),sideMat(0),sideD(0),sideT(0),
00028 sideAbsName(0),sideAbsMat(0),sideAbsW(0),detType(0),detdP1(0),detdP2(0),
00029 detT11(0),detT12(0),detTsc(0),detT21(0),detT22(0),detWidth1(0),detWidth2(0),
00030 detPosY(0) {
00031 LogDebug("HCalGeom") << "DDHCalBarrelAlgo info: Creating an instance";
00032 }
00033
00034 DDHCalBarrelAlgo::~DDHCalBarrelAlgo() {}
00035
00036
00037 void DDHCalBarrelAlgo::initialize(const DDNumericArguments & nArgs,
00038 const DDVectorArguments & vArgs,
00039 const DDMapArguments & ,
00040 const DDStringArguments & sArgs,
00041 const DDStringVectorArguments & vsArgs) {
00042
00043 genMaterial = sArgs["MaterialName"];
00044 nsectors = int (nArgs["NSector"]);
00045 nsectortot = int (nArgs["NSectorTot"]);
00046 nhalf = int (nArgs["NHalf"]);
00047 rin = nArgs["RIn"];
00048 rout = nArgs["ROut"];
00049 rzones = int (nArgs["RZones"]);
00050 rotHalf = sArgs["RotHalf"];
00051 rotns = sArgs["RotNameSpace"];
00052
00053 theta = vArgs["Theta"];
00054 rmax = vArgs["RMax"];
00055 zoff = vArgs["ZOff"];
00056 int i = 0;
00057 for (i = 0; i < rzones; i++) {
00058 ttheta.push_back(tan(theta[i]));
00059 }
00060 if (rzones > 3)
00061 rmax[2] = (zoff[3] - zoff[2]) / ttheta[2];
00062
00063 LogDebug("HCalGeom") << "DDHCalBarrelAlgo debug: General material "
00064 << genMaterial << "\tSectors " << nsectors << ", "
00065 << nsectortot <<"\tHalves " << nhalf
00066 << "\tRotation matrix " << rotns << ":" << rotHalf
00067 << "\n\t\t" << rin << "\t" << rout << "\t" << rzones;
00068 for (i = 0; i < rzones; i++) {
00069 LogDebug("HCalGeom") << "\tTheta[" << i << "] = " << theta[i] << "\trmax["
00070 << i << "] = " << rmax[i] << "\tzoff[" << i << "] = "
00071 << zoff[i];
00072 }
00074
00075 nLayers = int(nArgs["NLayers"]);
00076 LogDebug("HCalGeom") << "DDHCalBarrelAlgo debug: Layer\t" << nLayers;
00077 layerId = dbl_to_int (vArgs["Id"]);
00078 layerLabel = vsArgs["LayerLabel"];
00079 layerMat = vsArgs["LayerMat"];
00080 layerWidth = vArgs["LayerWidth"];
00081 layerD1 = vArgs["D1"];
00082 layerD2 = vArgs["D2"];
00083 layerAlpha = vArgs["Alpha2"];
00084 layerT1 = vArgs["T1"];
00085 layerT2 = vArgs["T2"];
00086 layerAbsorb = dbl_to_int(vArgs["AbsL"]);
00087 layerGap = vArgs["Gap"];
00088 for (i = 0; i < nLayers; i++) {
00089 LogDebug("HCalGeom") << layerLabel[i] << "\t" << layerId[i] << "\t"
00090 << layerMat[i] << "\t" << layerWidth[i] << "\t"
00091 << layerD1[i] << "\t" << layerD2[i] << "\t"
00092 << layerAlpha[i] << "\t" << layerT1[i] << "\t"
00093 << layerT2[i] << "\t" << layerAbsorb[i] << "\t"
00094 << layerGap[i];
00095 }
00096
00098
00099 absorbName = vsArgs["AbsorbName"];
00100 absorbMat = vsArgs["AbsorbMat"];
00101 absorbD = vArgs["AbsorbD"];
00102 absorbT = vArgs["AbsorbT"];
00103 nAbsorber = absorbName.size();
00104 for (i = 0; i < nAbsorber; i++) {
00105 LogDebug("HCalGeom") << "DDHCalBarrelAlgo debug: " << absorbName[i]
00106 <<" Material " << absorbMat[i] << " d " << absorbD[i]
00107 << " t " <<absorbT[i];
00108 }
00109 middleMat = sArgs["MiddleMat"];
00110 middleD = nArgs["MiddleD"];
00111 middleW = nArgs["MiddleW"];
00112 LogDebug("HCalGeom") << "DDHCalBarrelAlgo debug: Middle material "
00113 << middleMat << " d " << middleD << " w " << middleW;
00114 midName = vsArgs["MidAbsName"];
00115 midMat = vsArgs["MidAbsMat"];
00116 midW = vArgs["MidAbsW"];
00117 midT = vArgs["MidAbsT"];
00118 nMidAbs = midName.size();
00119 for (i = 0; i < nMidAbs; i++) {
00120 LogDebug("HCalGeom") << "DDHCalBarrelAlgo debug: " << midName[i]
00121 << " Material " << midMat[i] << " W " << midW[i]
00122 << " T " << midT[i];
00123 }
00124
00125
00126 sideMat = vsArgs["SideMat"];
00127 sideD = vArgs["SideD"];
00128 sideT = vArgs["SideT"];
00129 int nSide = sideMat.size();
00130 for (int i = 0; i < nSide; i++) {
00131 LogDebug("HCalGeom") << "DDHCalBarrelAlgo debug: Side material "
00132 << sideMat[i] << " d " << sideD[i] << " t "
00133 << sideT[i];
00134 }
00135 sideAbsName = vsArgs["SideAbsName"];
00136 sideAbsMat = vsArgs["SideAbsMat"];
00137 sideAbsW = vArgs["SideAbsW"];
00138 nSideAbs = sideAbsName.size();
00139 for (i = 0; i < nSideAbs; i++) {
00140 LogDebug("HCalGeom") << "DDHCalBarrelAlgo debug: " << sideAbsName[i]
00141 <<" Material " << sideAbsMat[i] << " W "
00142 << sideAbsW[i];
00143 }
00144
00146
00147
00148 detMat = sArgs["DetMat"];
00149 detRot = sArgs["DetRot"];
00150 detMatPl = sArgs["DetMatPl"];
00151 detMatSc = sArgs["DetMatSc"];
00152 LogDebug("HCalGeom") << "DDHCalBarrelAlgo debug: Detector (" << nLayers
00153 << ") Rotation matrix " << rotns << ":" << detRot
00154 << "\n\t\t" << detMat << "\t" << detMatPl << "\t"
00155 << detMatSc;
00156
00157 detType = dbl_to_int(vArgs["DetType"]);
00158 detdP1 = vArgs["DetdP1"];
00159 detdP2 = vArgs["DetdP2"];
00160 detT11 = vArgs["DetT11"];
00161 detT12 = vArgs["DetT12"];
00162 detTsc = vArgs["DetTsc"];
00163 detT21 = vArgs["DetT21"];
00164 detT22 = vArgs["DetT22"];
00165 detWidth1 = vArgs["DetWidth1"];
00166 detWidth2 = vArgs["DetWidth2"];
00167 detPosY = dbl_to_int(vArgs["DetPosY"]);
00168 for (i = 0; i < nLayers; i ++) {
00169 LogDebug("HCalGeom") << i+1 << "\t" << detType[i] << "\t" << detdP1[i]
00170 << ", " << detdP2[i] << "\t" << detT11[i] << ", "
00171 << detT12[i] << "\t" << detTsc[i] << "\t" << detT21[i]
00172 <<", " << detT22[i] << "\t" << detWidth1[i] << "\t"
00173 << detWidth2[i] << "\t" << detPosY[i];
00174 }
00175
00176
00177 idName = sArgs["MotherName"];
00178 idNameSpace = DDCurrentNamespace::ns();
00179 idOffset = int (nArgs["IdOffset"]);
00180 DDName parentName = parent().name();
00181 LogDebug("HCalGeom") << "DDHCalBarrelAlgo debug: Parent " << parentName
00182 <<" idName " << idName << " NameSpace " << idNameSpace
00183 << " Offset " << idOffset;
00184 }
00185
00187
00189
00190 void DDHCalBarrelAlgo::execute() {
00191
00192 LogDebug("HCalGeom") << "==>> Constructing DDHCalBarrelAlgo...";
00193 constructGeneralVolume();
00194 LogDebug("HCalGeom") << "<<== End of DDHCalBarrelAlgo construction ...";
00195 }
00196
00197
00198
00199 void DDHCalBarrelAlgo::constructGeneralVolume() {
00200
00201 LogDebug("HCalGeom") << "DDHCalBarrelAlgo test: General volume...";
00202 unsigned int i=0;
00203
00204 DDRotation rot = DDRotation();
00205
00206 double alpha = pi/getNsectors();
00207 double dphi = getNsectortot()*twopi/getNsectors();
00208 int nsec, ntot=15;
00209 if (getNhalf() == 1)
00210 nsec = 8;
00211 else
00212 nsec = 15;
00213 int nf = ntot - nsec;
00214
00215
00216
00217 double zmax = getZoff(3);
00218 double zstep5 = getZoff(4);
00219 double zstep4 =(getZoff(1) + getRmax(1)*getTanTheta(1));
00220 if ((getZoff(2)+getRmax(1)*getTanTheta(2)) > zstep4)
00221 zstep4 = (getZoff(2)+getRmax(1)*getTanTheta(2));
00222 double zstep3 =(getZoff(1) + getRmax(0)*getTanTheta(1));
00223 double zstep2 =(getZoff(0) + getRmax(0)*getTanTheta(0));
00224 double zstep1 =(getZoff(0) + getRin() *getTanTheta(0));
00225 double rout = getRout();
00226 double rout1 = getRmax(3);
00227 double rin = getRin();
00228 double rmid1 = getRmax(0);
00229 double rmid2 = getRmax(1);
00230 double rmid3 =(getZoff(4) - getZoff(2))/getTanTheta(2);
00231 double rmid4 = getRmax(2);
00232
00233 vector<double> pgonZ;
00234 pgonZ.push_back( -zmax);
00235 pgonZ.push_back( -zstep5);
00236 pgonZ.push_back( -zstep5);
00237 pgonZ.push_back( -zstep4);
00238 pgonZ.push_back( -zstep3);
00239 pgonZ.push_back( -zstep2);
00240 pgonZ.push_back( -zstep1);
00241 pgonZ.push_back( 0);
00242 pgonZ.push_back( zstep1);
00243 pgonZ.push_back( zstep2);
00244 pgonZ.push_back( zstep3);
00245 pgonZ.push_back( zstep4);
00246 pgonZ.push_back( zstep5);
00247 pgonZ.push_back( zstep5);
00248 pgonZ.push_back( zmax);
00249
00250 vector<double> pgonRmin;
00251 pgonRmin.push_back( rmid4);
00252 pgonRmin.push_back( rmid3);
00253 pgonRmin.push_back( rmid3);
00254 pgonRmin.push_back( rmid2);
00255 pgonRmin.push_back( rmid1);
00256 pgonRmin.push_back( rmid1);
00257 pgonRmin.push_back( rin);
00258 pgonRmin.push_back( rin);
00259 pgonRmin.push_back( rin);
00260 pgonRmin.push_back( rmid1);
00261 pgonRmin.push_back( rmid1);
00262 pgonRmin.push_back( rmid2);
00263 pgonRmin.push_back( rmid3);
00264 pgonRmin.push_back( rmid3);
00265 pgonRmin.push_back( rmid4);
00266
00267 vector<double> pgonRmax;
00268 pgonRmax.push_back( rout1);
00269 pgonRmax.push_back( rout1);
00270 pgonRmax.push_back( rout);
00271 pgonRmax.push_back( rout);
00272 pgonRmax.push_back( rout);
00273 pgonRmax.push_back( rout);
00274 pgonRmax.push_back( rout);
00275 pgonRmax.push_back( rout);
00276 pgonRmax.push_back( rout);
00277 pgonRmax.push_back( rout);
00278 pgonRmax.push_back( rout);
00279 pgonRmax.push_back( rout);
00280 pgonRmax.push_back( rout);
00281 pgonRmax.push_back( rout1);
00282 pgonRmax.push_back( rout1);
00283
00284 vector<double> pgonZHalf;
00285 pgonZHalf.push_back( 0);
00286 pgonZHalf.push_back( zstep1);
00287 pgonZHalf.push_back( zstep2);
00288 pgonZHalf.push_back( zstep3);
00289 pgonZHalf.push_back( zstep4);
00290 pgonZHalf.push_back( zstep5);
00291 pgonZHalf.push_back( zstep5);
00292 pgonZHalf.push_back( zmax);
00293
00294 vector<double> pgonRminHalf;
00295 pgonRminHalf.push_back( rin);
00296 pgonRminHalf.push_back( rin);
00297 pgonRminHalf.push_back( rmid1);
00298 pgonRminHalf.push_back( rmid1);
00299 pgonRminHalf.push_back( rmid2);
00300 pgonRminHalf.push_back( rmid3);
00301 pgonRminHalf.push_back( rmid3);
00302 pgonRminHalf.push_back( rmid4);
00303
00304 vector<double> pgonRmaxHalf;
00305 pgonRmaxHalf.push_back( rout);
00306 pgonRmaxHalf.push_back( rout);
00307 pgonRmaxHalf.push_back( rout);
00308 pgonRmaxHalf.push_back( rout);
00309 pgonRmaxHalf.push_back( rout);
00310 pgonRmaxHalf.push_back( rout);
00311 pgonRmaxHalf.push_back( rout1);
00312 pgonRmaxHalf.push_back( rout1);
00313
00314 string name("Null");
00315 DDSolid solid;
00316 if (nf == 0) {
00317 solid = DDSolidFactory::polyhedra(DDName(idName, idNameSpace),
00318 getNsectortot(), -alpha, dphi, pgonZ,
00319 pgonRmin, pgonRmax);
00320 LogDebug("HCalGeom") << "DDHCalBarrelAlgo test: "
00321 << DDName(idName, idNameSpace) <<" Polyhedra made of "
00322 << getGenMaterial() << " with " << getNsectortot()
00323 << " sectors from " << -alpha/deg <<" to "
00324 << (-alpha+dphi)/deg << " and with " << nsec
00325 << " sections ";
00326 for (i = 0; i <pgonZ.size(); i++) {
00327 LogDebug("HCalGeom") << "\t" << "\tZ = " << pgonZ[i] << "\tRmin = "
00328 << pgonRmin[i] << "\tRmax = " << pgonRmax[i];
00329 }
00330 } else {
00331 solid = DDSolidFactory::polyhedra(DDName(idName, idNameSpace),
00332 getNsectortot(), -alpha, dphi, pgonZHalf,
00333 pgonRminHalf, pgonRmaxHalf);
00334 LogDebug("HCalGeom") << "DDHCalBarrelAlgo test: "
00335 << DDName(idName, idNameSpace) <<" Polyhedra made of "
00336 << getGenMaterial() << " with " << getNsectortot()
00337 << " sectors from " << -alpha/deg << " to "
00338 << (-alpha+dphi)/deg << " and with " << nsec
00339 << " sections ";
00340 for (i = 0; i < pgonZHalf.size(); i++) {
00341 LogDebug("HCalGeom") << "\t" << "\tZ = " << pgonZHalf[i] << "\tRmin = "
00342 << pgonRminHalf[i] << "\tRmax = " <<pgonRmaxHalf[i];
00343 }
00344 }
00345
00346
00347 DDName matname(DDSplit(getGenMaterial()).first, DDSplit(getGenMaterial()).second);
00348 DDMaterial matter(matname);
00349 DDLogicalPart genlogic(DDName(idName, idNameSpace), matter, solid);
00350
00351 DDName parentName = parent().name();
00352 DDTranslation r0(0,0,0);
00353 DDpos(DDName(idName, idNameSpace), parentName, 1, r0, rot);
00354 LogDebug("HCalGeom") << "DDHCalBarrelAlgo test: "
00355 << DDName(idName, idNameSpace) << " number 1 positioned"
00356 << " in " << parentName << " at " << r0 <<" with "<<rot;
00357
00358
00359 name = idName + "Half";
00360 nf = (ntot+1)/2;
00361 LogDebug("HCalGeom") << "DDHCalBarrelAlgo test: " << DDName(name,idNameSpace)
00362 << " Polyhedra made of " << getGenMaterial() << " with "
00363 << getNsectortot() << " sectors from " << -alpha/deg
00364 << " to " << (-alpha+dphi)/deg << " and with " << nf
00365 << " sections ";
00366 for (i = 0; i < pgonZHalf.size(); i++) {
00367 LogDebug("HCalGeom") << "\t" << "\tZ = " << pgonZHalf[i] << "\tRmin = "
00368 << pgonRminHalf[i] << "\tRmax = " << pgonRmaxHalf[i];
00369 }
00370
00371 solid = DDSolidFactory::polyhedra(DDName(name, idNameSpace),
00372 getNsectortot(), -alpha, dphi, pgonZHalf,
00373 pgonRminHalf, pgonRmaxHalf);
00374 DDLogicalPart genlogich(DDName(name, idNameSpace), matter, solid);
00375
00376 DDpos(genlogich, genlogic, 1, r0, rot);
00377 LogDebug("HCalGeom") << "DDHCalBarrelAlgo test: " << genlogich.name()
00378 << " number 1 positioned in " << genlogic.name()
00379 << " at " << r0 << " with " << rot;
00380
00381 if (getNhalf() != 1) {
00382 rot = DDRotation(DDName(rotHalf, rotns));
00383 DDpos (genlogich, genlogic, 2, r0, rot);
00384 LogDebug("HCalGeom") << "DDHCalBarrelAlgo test: " << genlogich.name()
00385 << " number 2 positioned in " << genlogic.name()
00386 << " at " << r0 << " with " << rot;
00387 }
00388
00389
00390 name = idName + "Module";
00391 LogDebug("HCalGeom") << "DDHCalBarrelAlgo test: " << DDName(name,idNameSpace)
00392 << " Polyhedra made of " << getGenMaterial()
00393 << " with 1 sector from " << -alpha/deg << " to "
00394 << alpha/deg << " and with " << nf << " sections";
00395 for (i = 0; i < pgonZHalf.size(); i++) {
00396 LogDebug("HCalGeom") << "\t" << "\tZ = " << pgonZHalf[i] << "\tRmin = "
00397 << pgonRminHalf[i] << "\tRmax = " << pgonRmaxHalf[i];
00398 }
00399
00400 solid = DDSolidFactory::polyhedra(DDName(name, idNameSpace),
00401 1, -alpha, 2*alpha, pgonZHalf,
00402 pgonRminHalf, pgonRmaxHalf);
00403 DDLogicalPart seclogic(DDName(name, idNameSpace), matter, solid);
00404
00405 for (int ii=0; ii<getNsectortot(); ii++) {
00406 double phi = ii*2*alpha;
00407 double phideg = phi/deg;
00408
00409 DDRotation rotation;
00410 string rotstr("NULL");
00411 if (phideg != 0) {
00412 rotstr = "R";
00413 if (phideg < 100) rotstr = "R0";
00414 rotstr = rotstr + dbl_to_string(phideg);
00415 rotation = DDRotation(DDName(rotstr, rotns));
00416 if (!rotation) {
00417 LogDebug("HCalGeom") << "DDHCalBarrelAlgo test: Creating a new rotat"
00418 << "ion " << rotstr << "\t" << 90 << "," << phideg
00419 << "," << 90 << "," << (phideg+90) << ", 0, 0";
00420 rotation = DDrot(DDName(rotstr, rotns), 90*deg, phideg*deg,
00421 90*deg, (90+phideg)*deg, 0*deg, 0*deg);
00422 }
00423 }
00424
00425 DDpos (seclogic, genlogich, ii+1, r0, rotation);
00426 LogDebug("HCalGeom") << "DDHCalBarrelAlgo test: " << seclogic.name()
00427 << " number " << ii+1 << " positioned in "
00428 << genlogich.name() << " at " << r0 << " with "
00429 << rotation;
00430 }
00431
00432
00433 constructInsideSector(seclogic);
00434 }
00435
00436
00437 void DDHCalBarrelAlgo::constructInsideSector(DDLogicalPart sector) {
00438
00439 LogDebug("HCalGeom") << "DDHCalBarrelAlgo test: Layers (" << getNLayers()
00440 << ") ...";
00441
00442 double alpha = pi/getNsectors();
00443 double rin = getRin();
00444 for (int i = 0; i < getNLayers(); i++) {
00445 string name = idName + getLayerLabel(i);
00446 DDName matname(DDSplit(getLayerMaterial(i)).first,
00447 DDSplit(getLayerMaterial(i)).second);
00448 DDMaterial matter(matname);
00449
00450 double width = getLayerWidth(i);
00451 double rout = rin + width;
00452
00453 int in = 0, out = 0;
00454 for (int j = 0; j < getRzones()-1; j++) {
00455 if (rin >= getRmax(j)) in = j+1;
00456 if (rout> getRmax(j)) out= j+1;
00457 }
00458 double zout = getZoff(in) + rin*getTanTheta(in);
00459
00461
00462 double deltaz = 0;
00463 int nsec=2;
00464 vector<double> pgonZ, pgonRmin, pgonRmax;
00465
00466 pgonZ.push_back(0);
00467 pgonRmin.push_back(rin);
00468 pgonRmax.push_back(rout);
00469
00470 pgonZ.push_back(zout);
00471 pgonRmin.push_back(rin);
00472 pgonRmax.push_back(rout);
00473 if (in == out) {
00474 if (in <= 3) {
00475
00476 pgonZ.push_back(getZoff(in) + rout*getTanTheta(in));
00477 pgonRmin.push_back(pgonRmax[1]);
00478 pgonRmax.push_back(pgonRmax[1]);
00479 nsec++;
00480 }
00481 } else {
00482 if (in == 3) {
00483
00484 pgonZ[1] =(getZoff(out) + getRmax(out)*getTanTheta(out));
00485 pgonZ.push_back(pgonZ[1] + deltaz);
00486 pgonRmin.push_back(pgonRmin[1]);
00487 pgonRmax.push_back(getRmax(in));
00488
00489 pgonZ.push_back(getZoff(in) + getRmax(in)*getTanTheta(in));
00490 pgonRmin.push_back(pgonRmin[2]);
00491 pgonRmax.push_back(pgonRmax[2]);
00492 nsec += 2;
00493 } else {
00494
00495 pgonZ.push_back(getZoff(in) + getRmax(in)*getTanTheta(in));
00496 pgonRmin.push_back(getRmax(in));
00497 pgonRmax.push_back(pgonRmax[1]);
00498 nsec++;
00499 if (in == 0) {
00500 pgonZ.push_back(getZoff(out) + getRmax(in)*getTanTheta(out));
00501 pgonRmin.push_back(pgonRmin[2]);
00502 pgonRmax.push_back(pgonRmax[2]);
00503 nsec++;
00504 }
00505 if (in <= 1) {
00506 pgonZ.push_back(getZoff(out) + rout*getTanTheta(out));
00507 pgonRmin.push_back(rout);
00508 pgonRmax.push_back(rout);
00509 nsec++;
00510 }
00511 }
00512 }
00513
00514 DDSolid solid;
00515 double alpha1 = alpha;
00516 if (getLayerGap(i)>1.e-6) {
00517 double rmid = 0.5*(rin+rout);
00518 double width = rmid*tan(alpha) - getLayerGap(i);
00519 alpha1 = atan(width/rmid);
00520 LogDebug("HCalGeom") << "\t" << "Alpha_1 modified from " << alpha/deg
00521 << " to " << alpha1/deg << " Rmid " << rmid
00522 << " Reduced width " << width;
00523 }
00524 LogDebug("HCalGeom") << "DDHCalBarrelAlgo test: " << name << " (Layer "
00525 << i << ") Polyhedra made of " << getLayerMaterial(i)
00526 << " with 1 sector from " << -alpha1/deg << " to "
00527 << alpha1/deg << " and with " << nsec << " sections";
00528 for (unsigned int k=0; k<pgonZ.size(); k++) {
00529 LogDebug("HCalGeom") << "\t" << "\t" << pgonZ[k] << "\t" << pgonRmin[k]
00530 << "\t" << pgonRmax[k];
00531 }
00532 solid = DDSolidFactory::polyhedra(DDName(name, idNameSpace),
00533 1, -alpha1, 2*alpha1,
00534 pgonZ, pgonRmin, pgonRmax);
00535 DDLogicalPart glog(DDName(name, idNameSpace), matter, solid);
00536
00537 DDpos (glog, sector, getLayerId(i), DDTranslation(0.0, 0.0, 0.0),
00538 DDRotation());
00539 LogDebug("HCalGeom") << "DDHCalBarrelAlgo test: " << glog.name()
00540 << " number " << getLayerId(i) << " positioned in "
00541 << sector.name() << " at (0,0,0) with no rotation";
00542
00543 constructInsideLayers(glog, getLayerLabel(i), getLayerId(i),
00544 getLayerAbsorb(i), rin, getLayerD1(i), alpha1,
00545 getLayerD2(i), getLayerAlpha(i), getLayerT1(i),
00546 getLayerT2(i));
00547 rin = rout;
00548 }
00549
00550 }
00551
00552 void DDHCalBarrelAlgo::constructInsideLayers(DDLogicalPart laylog,
00553 string nm, int id, int nAbs,
00554 double rin, double d1,
00555 double alpha1, double d2,
00556 double alpha2, double t1,
00557 double t2) {
00558
00559 LogDebug("HCalGeom") << "DDHCalBarrelAlgo test: \t\tInside layer " << id
00560 << "...";
00561
00563
00564 DDRotation rot(DDName(detRot, rotns));
00565
00566 string nam0 = nm + "In";
00567 string name = idName + nam0;
00568 DDName matName(DDSplit(getDetMat()).first, DDSplit(getDetMat()).second);
00569 DDMaterial matter (matName);
00570
00571 DDSolid solid;
00572 DDLogicalPart glog, mother;
00573 double rsi, dx, dy, dz, x, y;
00574 int i, in;
00575
00576 if (alpha1 > 0) {
00577 rsi = rin + d1;
00578 in = 0;
00579 for (i = 0; i < getRzones()-1; i++) {
00580 if (rsi >= getRmax(i)) in = i+1;
00581 }
00582 dx = 0.5*t1;
00583 dy = 0.5*rsi*(tan(alpha1)-tan(alpha2));
00584 dz = 0.5*(getZoff(in) + rsi*getTanTheta(in));
00585 x = rsi + dx;
00586 y = 0.5*rsi*(tan(alpha1)+tan(alpha2));
00587 DDTranslation r11(x, y, dz);
00588 DDTranslation r12(x, -y, dz);
00589
00590 solid = DDSolidFactory::box(DDName(name+"1", idNameSpace), dx, dy, dz);
00591 LogDebug("HCalGeom") << "DDHCalBarrelAlgo test: " << solid.name()
00592 <<" Box made of " << getDetMat() << " of dimensions "
00593 << dx << ", " << dy << ", " << dz;
00594 glog = DDLogicalPart(solid.ddname(), matter, solid);
00595
00596 if (nAbs != 0) {
00597 mother = constructSideLayer(laylog, name, nAbs, rin, alpha1);
00598 } else {
00599 mother = laylog;
00600 }
00601 DDpos(glog, mother, idOffset+1, r11, DDRotation());
00602 DDpos(glog, mother, idOffset+2, r12, rot);
00603 LogDebug("HCalGeom") << "DDHCalBarrelAlgo test: " << glog.name()
00604 << " Number " << idOffset+1 << " positioned in "
00605 << mother.name() << " at " << r11
00606 << " with no rotation\n"
00607 << "DDHCalBarrelAlgo test: " << glog.name()
00608 << " Number " << idOffset+2 << " positioned in "
00609 << mother.name() << " at " << r12 << " with " << rot;
00610
00611
00612 constructInsideDetectors(glog, nam0+"1", id, dx, dy, dz, 1);
00613 }
00614
00615
00616 rsi = rin + d2;
00617 in = 0;
00618 for (i = 0; i < getRzones()-1; i++) {
00619 if (rsi >= getRmax(i)) in = i+1;
00620 }
00621 dx = 0.5*t2;
00622 dy = 0.5*rsi*tan(alpha2);
00623 dz = 0.5*(getZoff(in) + rsi*getTanTheta(in));
00624 x = rsi + dx;
00625 DDTranslation r21(x, dy, dz);
00626 DDTranslation r22(x, -dy, dz);
00627
00628 solid = DDSolidFactory::box(DDName(name+"2", idNameSpace), dx, dy, dz);
00629 LogDebug("HCalGeom") << "DDHCalBarrelAlgo test: " << solid.name()
00630 << " Box made of " << getDetMat() << " of dimensions "
00631 << dx << ", " << dy << ", " << dz;
00632 glog = DDLogicalPart(solid.ddname(), matter, solid);
00633
00634 if (nAbs < 0) {
00635 mother = constructMidLayer(laylog, name, rin, alpha1);
00636 } else {
00637 mother = laylog;
00638 }
00639 DDpos (glog, mother, idOffset+3, r21, DDRotation());
00640 DDpos (glog, mother, idOffset+4, r22, rot);
00641 LogDebug("HCalGeom") << "DDHCalBarrelAlgo test: " << glog.name() <<" Number "
00642 << idOffset+3 << " positioned in " << mother.name()
00643 << " at " << r21 << " with no rotation\n"
00644 << "DDHCalBarrelAlgo test: " << glog.name() <<" Number "
00645 << idOffset+4 << " positioned in " << mother.name()
00646 << " at " << r22 << " with " << rot;
00647
00648
00649 constructInsideDetectors(glog, nam0+"2", id, dx, dy, dz, 2);
00650 }
00651
00652 DDLogicalPart DDHCalBarrelAlgo::constructSideLayer(DDLogicalPart laylog,
00653 string nm, int nAbs,
00654 double rin, double alpha) {
00655
00656
00657 int k = abs(nAbs) - 1;
00658 string namek = nm + "Side";
00659 double rsi = rin + getSideD(k);
00660 int in = 0;
00661 for (int i = 0; i < getRzones()-1; i++) {
00662 if (rsi >= getRmax(i)) in = i+1;
00663 }
00664 vector<double> pgonZ, pgonRmin, pgonRmax;
00665
00666 pgonZ.push_back(0.0);
00667 pgonRmin.push_back(rsi);
00668 pgonRmax.push_back(rsi+getSideT(k));
00669
00670 pgonZ.push_back(getZoff(in) + rsi*getTanTheta(in));
00671 pgonRmin.push_back(rsi);
00672 pgonRmax.push_back(pgonRmax[0]);
00673
00674 pgonZ.push_back(getZoff(in) + pgonRmax[0]*getTanTheta(in));
00675 pgonRmin.push_back(pgonRmax[1]);
00676 pgonRmax.push_back(pgonRmax[1]);
00677 DDSolid solid = DDSolidFactory::polyhedra(DDName(namek, idNameSpace), 1,
00678 -alpha, 2*alpha, pgonZ, pgonRmin,
00679 pgonRmax);
00680 LogDebug("HCalGeom") << "DDHCalBarrelAlgo test: " << solid.name()
00681 << " Polyhedra made of " << getSideMat(k)
00682 << " with 1 sector from " << -alpha/deg
00683 << " to " << alpha/deg << " and with "
00684 << pgonZ.size() << " sections";
00685 for (unsigned int ii=0; ii<pgonZ.size(); ii++) {
00686 LogDebug("HCalGeom") << "\t\tZ = " << pgonZ[ii] << "\tRmin = "
00687 << pgonRmin[ii] << "\tRmax = " << pgonRmax[ii];
00688 }
00689
00690 DDName matName(DDSplit(getSideMat(k)).first, DDSplit(getSideMat(k)).second);
00691 DDMaterial matter(matName);
00692 DDLogicalPart glog = DDLogicalPart(solid.ddname(), matter, solid);
00693
00694 DDpos(glog, laylog, 1, DDTranslation(), DDRotation());
00695 LogDebug("HCalGeom") << "DDHCalBarrelAlgo test: " << glog.name()
00696 << " Number 1 positioned in " << laylog.name()
00697 << " at (0,0,0) with no rotation";
00698
00699 if (nAbs < 0) {
00700 DDLogicalPart mother = glog;
00701 double rmid = pgonRmax[0];
00702 for (int i = 0; i < getSideAbsorber(); i++) {
00703 double alpha1 = atan(getSideAbsW(i)/rmid);
00704 if (alpha1 > 0) {
00705 string name = namek + getSideAbsName(i);
00706 solid = DDSolidFactory::polyhedra(DDName(name, idNameSpace), 1,
00707 -alpha1, 2*alpha1, pgonZ, pgonRmin,
00708 pgonRmax);
00709 LogDebug("HCalGeom") << "DDHCalBarrelAlgo test: " << solid.name()
00710 << " Polyhedra made of " << getSideAbsMat(i)
00711 << " with 1 sector from " << -alpha1/deg
00712 << " to " << alpha1/deg << " and with "
00713 << pgonZ.size() << " sections";
00714 for (unsigned int ii=0; ii<pgonZ.size(); ii++) {
00715 LogDebug("HCalGeom") << "\t\tZ = " << pgonZ[ii] << "\tRmin = "
00716 << pgonRmin[ii] << "\tRmax = " << pgonRmax[ii];
00717 }
00718
00719 DDName matName(DDSplit(getSideAbsMat(i)).first,
00720 DDSplit(getSideAbsMat(i)).second);
00721 DDMaterial matter(matName);
00722 DDLogicalPart log = DDLogicalPart(solid.ddname(), matter, solid);
00723
00724 DDpos(log, mother, 1, DDTranslation(), DDRotation());
00725 LogDebug("HCalGeom") << "DDHCalBarrelAlgo test: " << log.name()
00726 << " Number 1 positioned in " << mother.name()
00727 << " at (0,0,0) with no rotation";
00728 mother = log;
00729 }
00730 }
00731 }
00732 return glog;
00733 }
00734
00735 DDLogicalPart DDHCalBarrelAlgo::constructMidLayer(DDLogicalPart laylog,
00736 string nm, double rin,
00737 double alpha) {
00738
00739 DDSolid solid;
00740 DDLogicalPart log, glog;
00741 string name = nm + "Mid";
00742 for (int k=0; k < getAbsorberN(); k++) {
00743 string namek = name + getAbsorbName(k);
00744 double rsi = rin + getAbsorbD(k);
00745 int in = 0;
00746 for (int i = 0; i < getRzones()-1; i++) {
00747 if (rsi >= getRmax(i)) in = i+1;
00748 }
00749 vector<double> pgonZ, pgonRmin, pgonRmax;
00750
00751 pgonZ.push_back(0.0);
00752 pgonRmin.push_back(rsi);
00753 pgonRmax.push_back(rsi+getAbsorbT(k));
00754
00755 pgonZ.push_back(getZoff(in) + rsi*getTanTheta(in));
00756 pgonRmin.push_back(rsi);
00757 pgonRmax.push_back(pgonRmax[0]);
00758
00759 pgonZ.push_back(getZoff(in) + pgonRmax[0]*getTanTheta(in));
00760 pgonRmin.push_back(pgonRmax[1]);
00761 pgonRmax.push_back(pgonRmax[1]);
00762 solid = DDSolidFactory::polyhedra(DDName(namek, idNameSpace), 1, -alpha,
00763 2*alpha, pgonZ, pgonRmin, pgonRmax);
00764 LogDebug("HCalGeom") << "DDHCalBarrelAlgo test: " << solid.name()
00765 << " Polyhedra made of " << getAbsorbMat(k)
00766 << " with 1 sector from " << -alpha/deg
00767 << " to " << alpha/deg << " and with "
00768 << pgonZ.size() << " sections";
00769 for (unsigned int ii=0; ii<pgonZ.size(); ii++) {
00770 LogDebug("HCalGeom") << "\t\tZ = " << pgonZ[ii] << "\tRmin = "
00771 << pgonRmin[ii] << "\tRmax = " << pgonRmax[ii];
00772 }
00773
00774 DDName matName(DDSplit(getAbsorbMat(k)).first, DDSplit(getAbsorbMat(k)).second);
00775 DDMaterial matter(matName);
00776 log = DDLogicalPart(solid.ddname(), matter, solid);
00777
00778 DDpos(log, laylog, 1, DDTranslation(), DDRotation());
00779 LogDebug("HCalGeom") << "DDHCalBarrelAlgo test: " << log.name()
00780 << " Number 1 positioned in " << laylog.name()
00781 << " at (0,0,0) with no rotation";
00782
00783 if (k==0) {
00784 double rmin = pgonRmin[0];
00785 double rmax = pgonRmax[0];
00786 DDLogicalPart mother = log;
00787 for (int i=0; i<1; i++) {
00788 double alpha1 = atan(getMidAbsW(i)/rmin);
00789 string namek = name + getMidAbsName(i);
00790 solid = DDSolidFactory::polyhedra(DDName(namek, idNameSpace), 1,
00791 -alpha1, 2*alpha1, pgonZ, pgonRmin,
00792 pgonRmax);
00793 LogDebug("HCalGeom") << "DDHCalBarrelAlgo test: " << solid.name()
00794 << " Polyhedra made of " << getMidAbsMat(i)
00795 << " with 1 sector from " << -alpha1/deg
00796 << " to " << alpha1/deg << " and with "
00797 << pgonZ.size() << " sections";
00798 for (unsigned int ii=0; ii<pgonZ.size(); ii++) {
00799 LogDebug("HCalGeom") << "\t\tZ = " << pgonZ[ii] << "\tRmin = "
00800 << pgonRmin[ii] << "\tRmax = " << pgonRmax[ii];
00801 }
00802
00803 DDName matNam1(DDSplit(getMidAbsMat(i)).first,
00804 DDSplit(getMidAbsMat(i)).second);
00805 DDMaterial matter1(matNam1);
00806 log = DDLogicalPart(solid.ddname(), matter1, solid);
00807
00808 DDpos(log, mother, 1, DDTranslation(), DDRotation());
00809 LogDebug("HCalGeom") << "DDHCalBarrelAlgo test: " << log.name()
00810 << " Number 1 positioned in " << mother.name()
00811 << " at (0,0,0) with no rotation";
00812 mother = log;
00813 }
00814
00815
00816 double rmid = rmin + getMiddleD();
00817 pgonRmin[0] = rmid; pgonRmax[0] = rmax;
00818 pgonRmin[1] = rmid; pgonRmax[1] = rmax; pgonZ[1] = getZoff(in) + rmid*getTanTheta(in);
00819 pgonRmin[2] = rmax; pgonRmax[2] = rmax; pgonZ[2] = getZoff(in) + rmax*getTanTheta(in);
00820 double alpha1 = atan(getMiddleW()/rmin);
00821 solid = DDSolidFactory::polyhedra(DDName(name, idNameSpace), 1,
00822 -alpha1, 2*alpha1, pgonZ, pgonRmin,
00823 pgonRmax);
00824 LogDebug("HCalGeom") << "DDHCalBarrelAlgo test: " << solid.name()
00825 << " Polyhedra made of " << getMiddleMat()
00826 << " with 1 sector from " << -alpha1/deg
00827 << " to " << alpha1/deg << " and with "
00828 << pgonZ.size() << " sections";
00829 for (unsigned int ii=0; ii<pgonZ.size(); ii++) {
00830 LogDebug("HCalGeom") << "\t\tZ = " << pgonZ[ii] << "\tRmin = "
00831 << pgonRmin[ii] << "\tRmax = " << pgonRmax[ii];
00832 }
00833
00834 DDName matNam1(DDSplit(getMiddleMat()).first,
00835 DDSplit(getMiddleMat()).second);
00836 DDMaterial matter1(matNam1);
00837 glog = DDLogicalPart(solid.ddname(), matter1, solid);
00838
00839 DDpos(glog, mother, 1, DDTranslation(), DDRotation());
00840 LogDebug("HCalGeom") << "DDHCalBarrelAlgo test: " << glog.name()
00841 << " Number 1 positioned in " << mother.name()
00842 << " at (0,0,0) with no rotation";
00843
00844
00845 for (int i = 1; i < getMidAbsorber(); i++) {
00846 namek = name + getMidAbsName(i);
00847 rmid = rmin + getMidAbsT(i);
00848 pgonRmin[0] = rmin; pgonRmax[0] = rmid;
00849 pgonRmin[1] = rmin; pgonRmax[1] = rmid; pgonZ[1] = getZoff(in) + rmin*getTanTheta(in);
00850 pgonRmin[2] = rmid; pgonRmax[2] = rmid; pgonZ[2] = getZoff(in) + rmid*getTanTheta(in);
00851 alpha1 = atan(getMidAbsW(i)/rmin);
00852 solid = DDSolidFactory::polyhedra(DDName(namek, idNameSpace), 1,
00853 -alpha1, 2*alpha1, pgonZ, pgonRmin,
00854 pgonRmax);
00855 LogDebug("HCalGeom") << "DDHCalBarrelAlgo test: " << solid.name()
00856 << " Polyhedra made of " << getMidAbsMat(i)
00857 << " with 1 sector from " << -alpha1/deg
00858 << " to " << alpha1/deg << " and with "
00859 << pgonZ.size() << " sections";
00860 for (unsigned int ii=0; ii<pgonZ.size(); ii++) {
00861 LogDebug("HCalGeom") << "\t\tZ = " << pgonZ[ii] << "\tRmin = "
00862 << pgonRmin[ii] << "\tRmax = " << pgonRmax[ii];
00863 }
00864
00865 DDName matName2(DDSplit(getMidAbsMat(i)).first,
00866 DDSplit(getMidAbsMat(i)).second);
00867 DDMaterial matter2(matName2);
00868 log = DDLogicalPart(solid.ddname(), matter2, solid);
00869
00870 DDpos(log, mother, i, DDTranslation(), DDRotation());
00871 LogDebug("HCalGeom") << "DDHCalBarrelAlgo test: " << log.name()
00872 << " Number " << i << " positioned in "
00873 << mother.name() << " at (0,0,0) with no "
00874 << "rotation";
00875 mother = log;
00876 }
00877 }
00878 }
00879 return glog;
00880 }
00881
00882 void DDHCalBarrelAlgo::constructInsideDetectors(DDLogicalPart detector,
00883 string name, int id, double dx,
00884 double dy, double dz,
00885 int type) {
00886
00887 LogDebug("HCalGeom") << "DDHCalBarrelAlgo test: \t\tInside detector " << id
00888 << "...";
00889
00890 DDName plmatname(DDSplit(getDetMatPl()).first, DDSplit(getDetMatPl()).second);
00891 DDMaterial plmatter(plmatname);
00892 DDName scmatname(DDSplit(getDetMatSc()).first, DDSplit(getDetMatSc()).second);
00893 DDMaterial scmatter(scmatname);
00894
00895 string plname = detector.name().name()+"Plastic_";
00896 string scname = idName+"Scintillator"+name;
00897
00898 id--;
00899 DDSolid solid;
00900 DDLogicalPart glog;
00901 double wid, y=0;
00902 double dx1, dx2, shiftX;
00903
00904 if (type == 1) {
00905 wid = 0.5*getDetWidth1(id);
00906 if (getDetPosY(id)>0) y =-dy+wid;
00907 dx1 = 0.5*getDetT11(id);
00908 dx2 = 0.5*getDetT21(id);
00909 shiftX = getDetdP1(id);
00910 } else {
00911 wid = 0.5*getDetWidth2(id);
00912 dx1 = 0.5*getDetT12(id);
00913 dx2 = 0.5*getDetT22(id);
00914 shiftX = getDetdP2(id);
00915 }
00916
00917 solid = DDSolidFactory::box(DDName(plname+"1", idNameSpace), dx1, wid, dz);
00918 LogDebug("HCalGeom") << "DDHCalBarrelAlgo test: " << solid.name()
00919 << " Box made of " << getDetMatPl() << " of dimensions "
00920 << dx1 <<", " << wid << ", " << dz;
00921 glog = DDLogicalPart(solid.ddname(), plmatter, solid);
00922
00923 double x = shiftX + dx1 - dx;
00924 DDpos(glog, detector, 1, DDTranslation(x,y,0), DDRotation());
00925 LogDebug("HCalGeom") << "DDHCalBarrelAlgo test: " << glog.name()
00926 << " Number 1 positioned in " << detector.name()
00927 << " at (" << x << "," << y << ",0) with no rotation";
00928
00929 solid = DDSolidFactory::box(DDName(scname, idNameSpace),
00930 0.5*getDetTsc(id), wid, dz);
00931 LogDebug("HCalGeom") << "DDHCalBarrelAlgo test: " << solid.name()
00932 << " Box made of " << getDetMatSc() << " of dimensions "
00933 << 0.5*getDetTsc(id) << ", " << wid << ", " << dz;
00934 glog = DDLogicalPart(solid.ddname(), scmatter, solid);
00935
00936 x += dx1 + 0.5*getDetTsc(id);
00937 int copyNo = id*10 + getDetType(id);
00938 DDpos(glog, detector, copyNo, DDTranslation(x, y, 0), DDRotation());
00939 LogDebug("HCalGeom") << "DDHCalBarrelAlgo test: " << glog.name() <<" Number "
00940 << copyNo << " positioned in " << detector.name()
00941 << " at (" << x << "," << y << ",0) with no rotation";
00942
00943 solid = DDSolidFactory::box(DDName(plname+"2", idNameSpace), dx2, wid, dz);
00944 LogDebug("HCalGeom") << "DDHCalBarrelAlgo test: " << solid.name()
00945 << " Box made of " << getDetMatPl() << " of dimensions "
00946 << dx2 <<", " << wid << ", " << dz;
00947 glog = DDLogicalPart(solid.ddname(), plmatter, solid);
00948
00949 x+=0.5*getDetTsc(id) + dx2;
00950 DDpos (glog, detector, 1, DDTranslation(x, y, 0), DDRotation());
00951 LogDebug("HCalGeom") << "DDHCalBarrelAlgo test: " << glog.name()
00952 << " Number 1 positioned in " << detector.name()
00953 << " at (" << x << "," << y << ",0) with no rotation";
00954
00955 }