CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_4_1_8_patch12/src/Geometry/TrackerCommonData/src/DDTOBAxCableAlgo.cc

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