00001
00002
00003
00005
00006 #include <cmath>
00007 #include <algorithm>
00008
00009 #include "FWCore/MessageLogger/interface/MessageLogger.h"
00010 #include "DetectorDescription/Base/interface/DDutils.h"
00011 #include "DetectorDescription/Core/interface/DDPosPart.h"
00012 #include "DetectorDescription/Core/interface/DDLogicalPart.h"
00013 #include "DetectorDescription/Core/interface/DDSolid.h"
00014 #include "DetectorDescription/Core/interface/DDMaterial.h"
00015 #include "DetectorDescription/Core/interface/DDCurrentNamespace.h"
00016 #include "DetectorDescription/Core/interface/DDSplit.h"
00017 #include "Geometry/TrackerCommonData/interface/DDTECAxialCableAlgo.h"
00018 #include "CLHEP/Units/PhysicalConstants.h"
00019 #include "CLHEP/Units/SystemOfUnits.h"
00020
00021 DDTECAxialCableAlgo::DDTECAxialCableAlgo() {
00022 LogDebug("TECGeom") << "DDTECAxialCableAlgo info: Creating an instance";
00023 }
00024
00025 DDTECAxialCableAlgo::~DDTECAxialCableAlgo() {}
00026
00027 void DDTECAxialCableAlgo::initialize(const DDNumericArguments & nArgs,
00028 const DDVectorArguments & vArgs,
00029 const DDMapArguments & ,
00030 const DDStringArguments & sArgs,
00031 const DDStringVectorArguments & ) {
00032
00033 n = int(nArgs["N"]);
00034 rangeAngle = nArgs["RangeAngle"];
00035 zStart = nArgs["ZStart"];
00036 zEnd = nArgs["ZEnd"];
00037 rMin = nArgs["RMin"];
00038 rMax = nArgs["RMax"];
00039 width = nArgs["Width"];
00040 thickR = nArgs["ThickR"];
00041 thickZ = nArgs["ThickZ"];
00042 dZ = nArgs["DZ"];
00043 startAngle = vArgs["StartAngle"];
00044 zPos = vArgs["ZPos"];
00045
00046 if (fabs(rangeAngle-360.0*deg)<0.001*deg) {
00047 delta = rangeAngle/double(n);
00048 } else {
00049 if (n > 1) {
00050 delta = rangeAngle/double(n-1);
00051 } else {
00052 delta = 0.;
00053 }
00054 }
00055
00056 LogDebug("TECGeom") << "DDTECAxialCableAlgo debug: Parameters for creating "
00057 << startAngle.size() << " axial cables and positioning "
00058 << n << " copies in Service volume\n"
00059 << " zStart " << zStart
00060 << " zEnd " << zEnd << " rMin " << rMin << " rMax "
00061 << rMax << " Cable width " << width/deg << " thickness "
00062 << thickR << ", " << thickZ << " dZ " << dZ << "\n"
00063 << " Range, Delta "
00064 << rangeAngle/deg << ", " << delta/deg;
00065 for (int i=0; i<(int)(startAngle.size()); i++)
00066 LogDebug("TECGeom") << " Cable " << i
00067 << " from Z " << zPos[i] << " startAngle "
00068 << startAngle[i]/deg;
00069 idNameSpace = DDCurrentNamespace::ns();
00070 childName = sArgs["ChildName"];
00071 matName = sArgs["Material"];
00072
00073 DDName parentName = parent().name();
00074
00075 LogDebug("TECGeom") << "DDTECAxialCableAlgo debug: Parent " << parentName
00076 << "\tChild " << childName << " NameSpace "
00077 << idNameSpace << "\tMaterial " << matName;
00078 }
00079
00080 void DDTECAxialCableAlgo::execute() {
00081
00082 DDName mother = parent().name();
00083 double theta = 90.*deg;
00084
00085 for (int k=0; k<(int)(startAngle.size()); k++) {
00086
00087 int i;
00088 double zv = zPos[k]-dZ-0.5*(zStart+zEnd);
00089 std::vector<double> pconZ, pconRmin, pconRmax;
00090 pconZ.push_back(zv);
00091 pconRmin.push_back(rMin);
00092 pconRmax.push_back(rMax);
00093 pconZ.push_back(zv+thickZ);
00094 pconRmin.push_back(rMin);
00095 pconRmax.push_back(rMax);
00096 pconZ.push_back(zv+thickZ);
00097 pconRmin.push_back(rMax-thickR);
00098 pconRmax.push_back(rMax);
00099 zv = zPos[k]+dZ-0.5*(zStart+zEnd);
00100 pconZ.push_back(zv-thickZ);
00101 pconRmin.push_back(rMax-thickR);
00102 pconRmax.push_back(rMax);
00103 pconZ.push_back(zv-thickZ);
00104 pconRmin.push_back(rMin);
00105 pconRmax.push_back(rMax);
00106 pconZ.push_back(zv);
00107 pconRmin.push_back(rMin);
00108 pconRmax.push_back(rMax);
00109 pconZ.push_back(zv);
00110 pconRmin.push_back(rMax-thickR);
00111 pconRmax.push_back(rMax);
00112 pconZ.push_back(0.5*(zEnd-zStart));
00113 pconRmin.push_back(rMax-thickR);
00114 pconRmax.push_back(rMax);
00115
00116 std::string name = childName + dbl_to_string(k);
00117 DDSolid solid = DDSolidFactory::polycone(DDName(name, idNameSpace),
00118 -0.5*width, width, pconZ,
00119 pconRmin, pconRmax);
00120
00121 LogDebug("TECGeom") << "DDTECAxialCableAlgo test: "
00122 << DDName(name, idNameSpace) <<" Polycone made of "
00123 << matName << " from " << -0.5*width/deg << " to "
00124 << 0.5*width/deg << " and with " << pconZ.size()
00125 << " sections ";
00126 for (int ii = 0; ii <(int)(pconZ.size()); ii++)
00127 LogDebug("TECGeom") << "\t" << "\tZ[" << ii << "] = " << pconZ[ii]
00128 << "\tRmin[" << ii << "] = "<< pconRmin[ii]
00129 << "\tRmax[" << ii << "] = " << pconRmax[ii];
00130 DDName mat(DDSplit(matName).first, DDSplit(matName).second);
00131 DDMaterial matter(mat);
00132 DDLogicalPart genlogic(DDName(name, idNameSpace), matter, solid);
00133
00134 double phi = startAngle[k];
00135 for (i=0; i<n; i++) {
00136 double phix = phi;
00137 double phiy = phix + 90.*deg;
00138 double phideg = phix/deg;
00139
00140 DDRotation rotation;
00141 if (phideg != 0) {
00142 std::string rotstr = childName + dbl_to_string(phideg*10.);
00143 rotation = DDRotation(DDName(rotstr, idNameSpace));
00144 if (!rotation) {
00145 LogDebug("TECGeom") << "DDTECAxialCableAlgo test: Creating a new"
00146 << " rotation: " << rotstr << "\t90., "
00147 << phix/deg << ", 90.," << phiy/deg
00148 << ", 0, 0";
00149 rotation = DDrot(DDName(rotstr, idNameSpace), theta, phix, theta,
00150 phiy, 0., 0.);
00151 }
00152 }
00153
00154 DDTranslation tran(0,0,0);
00155 DDpos (DDName(name, idNameSpace), mother, i+1, tran, rotation);
00156 LogDebug("TECGeom") << "DDTECAxialCableAlgo test "
00157 << DDName(name, idNameSpace) << " number " << i+1
00158 << " positioned in " << mother << " at " << tran
00159 << " with " << rotation;
00160
00161 phi += delta;
00162 }
00163 }
00164 }