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