00001
00002
00003
00005
00006 #include <cmath>
00007 #include <algorithm>
00008
00009 #include "FWCore/MessageLogger/interface/MessageLogger.h"
00010 #include "DetectorDescription/Core/interface/DDPosPart.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/interface/DDTOBAxCableAlgo.h"
00017 #include "CLHEP/Units/PhysicalConstants.h"
00018 #include "CLHEP/Units/SystemOfUnits.h"
00019
00020
00021 DDTOBAxCableAlgo::DDTOBAxCableAlgo():
00022 sectorRin(0),sectorRout(0),sectorDeltaPhi_B(0) {
00023 LogDebug("TOBGeom") <<"DDTOBAxCableAlgo info: Creating an instance";
00024 }
00025
00026 DDTOBAxCableAlgo::~DDTOBAxCableAlgo() {}
00027
00028 void DDTOBAxCableAlgo::initialize(const DDNumericArguments & nArgs,
00029 const DDVectorArguments & vArgs,
00030 const DDMapArguments &,
00031 const DDStringArguments & sArgs,
00032 const DDStringVectorArguments & vsArgs) {
00033
00034 idNameSpace = DDCurrentNamespace::ns();
00035 DDName parentName = parent().name();
00036 LogDebug("TOBGeom") << "DDTOBAxCableAlgo debug: Parent " << parentName
00037 << " NameSpace " << idNameSpace;
00038
00039 sectorNumber = vsArgs["SectorNumber"];
00040 sectorRin = nArgs["SectorRin"];
00041 sectorRout = nArgs["SectorRout"];
00042 sectorDz = nArgs["SectorDz"];
00043 sectorDeltaPhi_B = nArgs["SectorDeltaPhi_B"];
00044 sectorStartPhi = vArgs["SectorStartPhi"];
00045 sectorMaterial_A = vsArgs["SectorMaterial_A"];
00046 sectorMaterial_B = vsArgs["SectorMaterial_B"];
00047 sectorMaterial_C = vsArgs["SectorMaterial_C"];
00048
00049 for (int i=0; i<(int)(sectorNumber.size()); i++)
00050 LogDebug("TOBGeom") << "DDTOBAxCableAlgo debug: sectorNumber[" << i
00051 << "] = " << sectorNumber[i];
00052
00053 LogDebug("TOBGeom") << "DDTOBAxCableAlgo debug: Axial Service Sectors half-length " << sectorDz
00054 << "\tRin " << sectorRin << "\tRout = " << sectorRout
00055 << "\tPhi of sectors position:";
00056 for (int i=0; i<(int)(sectorNumber.size()); i++)
00057 LogDebug("TOBGeom") << "\t[" << i << "]\tPhi = " << sectorStartPhi[i];
00058 LogDebug("TOBGeom") << "DDTOBAxCableAlgo debug: List of materials for the sectors/3 parts";
00059
00060 LogDebug("TOBGeom") << "DDTOBAxCableAlgo debug: Sector/3 A";
00061 for (int i=0; i<(int)(sectorNumber.size()); i++)
00062 LogDebug("TOBGeom") << "\t[" << i << "]\tsectorMaterial_A = " << sectorMaterial_A[i];
00063
00064 LogDebug("TOBGeom") << "DDTOBAxCableAlgo debug: Sector/3 B";
00065 for (int i=0; i<(int)(sectorNumber.size()); i++)
00066 LogDebug("TOBGeom") << "\t[" << i << "]\tsectorMaterial_B = " << sectorMaterial_B[i];
00067
00068 LogDebug("TOBGeom") << "DDTOBAxCableAlgo debug: Sector/3 C";
00069 for (int i=0; i<(int)(sectorNumber.size()); i++)
00070 LogDebug("TOBGeom") << "\t[" << i << "]\tsectorMaterial_C = " << sectorMaterial_C[i];
00071
00072 }
00073
00074 void DDTOBAxCableAlgo::execute() {
00075
00076 LogDebug("TOBGeom") << "==>> Constructing DDTOBAxCableAlgo...";
00077 DDName tubsName = parent().name();
00078
00079
00080 for (int i=0; i<(int)(sectorNumber.size()); i++) {
00081
00082 DDSolid solid;
00083 std::string name;
00084 double dz, rin, rout, startphi, widthphi, deltaphi;
00085
00086
00087
00088
00089 widthphi = ( (i+1 == (int)(sectorStartPhi.size())) ?
00090 (sectorStartPhi[0]+twopi)-sectorStartPhi[i] : (sectorStartPhi[i+1]-sectorStartPhi[i]) );
00091
00092
00093 name = "TOBAxService_" + sectorNumber[i] + "A";
00094 dz = sectorDz;
00095 rin = sectorRin;
00096 rout = sectorRout;
00097 startphi = sectorStartPhi[i];
00098 deltaphi = 0.5 * (widthphi - sectorDeltaPhi_B);
00099
00100 solid = DDSolidFactory::tubs(DDName(name, idNameSpace), dz, rin,
00101 rout, startphi, deltaphi);
00102
00103 LogDebug("TOBGeom") << "DDTOBAxCableAlgo test: "
00104 << DDName(name, idNameSpace) << " Tubs made of "
00105 << sectorMaterial_A[i] << " from " << startphi/deg << " to " << (startphi+deltaphi)/deg
00106 << " with Rin " << rin << " Rout " << rout
00107 << " ZHalf " << dz;
00108
00109 DDName sectorMatName(DDSplit(sectorMaterial_A[i]).first, DDSplit(sectorMaterial_A[i]).second);
00110 DDMaterial sectorMatter(sectorMatName);
00111 DDLogicalPart sectorLogic(DDName(name, idNameSpace), sectorMatter, solid);
00112
00113 DDpos(DDName(name,idNameSpace), tubsName, i+1, DDTranslation(), DDRotation());
00114 LogDebug("TOBGeom") << "DDTOBAxCableAlgo test: "
00115 << DDName(name,idNameSpace) << " number " << i+1
00116 << " positioned in " << tubsName << " with no translation and no rotation";
00117
00118
00119 name = "TOBAxService_" + sectorNumber[i] + "B";
00120 startphi += deltaphi;
00121 deltaphi = sectorDeltaPhi_B;
00122
00123 solid = DDSolidFactory::tubs(DDName(name, idNameSpace), dz, rin,
00124 rout, startphi, deltaphi);
00125
00126 LogDebug("TOBGeom") << "DDTOBAxCableAlgo test: "
00127 << DDName(name, idNameSpace) << " Tubs made of "
00128 << sectorMaterial_B[i] << " from " << startphi/deg << " to " << (startphi+deltaphi)/deg
00129 << " with Rin " << rin << " Rout " << rout
00130 << " ZHalf " << dz;
00131
00132 sectorMatName = DDName(DDSplit(sectorMaterial_B[i]).first, DDSplit(sectorMaterial_B[i]).second);
00133 sectorMatter = DDMaterial(sectorMatName);
00134 sectorLogic = DDLogicalPart(DDName(name, idNameSpace), sectorMatter, solid);
00135
00136 DDpos(DDName(name,idNameSpace), tubsName, i+1, DDTranslation(), DDRotation());
00137 LogDebug("TOBGeom") << "DDTOBAxCableAlgo test: "
00138 << DDName(name,idNameSpace) << " number " << i+1
00139 << " positioned in " << tubsName << " with no translation and no rotation";
00140
00141
00142 name = "TOBAxService_" + sectorNumber[i] + "C";
00143 startphi += deltaphi;
00144 deltaphi = 0.5 * (widthphi - sectorDeltaPhi_B);
00145
00146 solid = DDSolidFactory::tubs(DDName(name, idNameSpace), dz, rin,
00147 rout, startphi, deltaphi);
00148
00149 LogDebug("TOBGeom") << "DDTOBAxCableAlgo test: "
00150 << DDName(name, idNameSpace) << " Tubs made of "
00151 << sectorMaterial_C[i] << " from " << startphi/deg << " to " << (startphi+deltaphi)/deg
00152 << " with Rin " << rin << " Rout " << rout
00153 << " ZHalf " << dz;
00154
00155 sectorMatName = DDName(DDSplit(sectorMaterial_C[i]).first, DDSplit(sectorMaterial_C[i]).second);
00156 sectorMatter = DDMaterial(sectorMatName);
00157 sectorLogic = DDLogicalPart(DDName(name, idNameSpace), sectorMatter, solid);
00158
00159 DDpos(DDName(name,idNameSpace), tubsName, i+1, DDTranslation(), DDRotation());
00160 LogDebug("TOBGeom") << "DDTOBAxCableAlgo test: "
00161 << DDName(name,idNameSpace) << " number " << i+1
00162 << " positioned in " << tubsName << " with no translation and no rotation";
00163
00164 }
00165
00166 LogDebug("TOBGeom") << "<<== End of DDTOBAxCableAlgo construction ...";
00167 }