CMS 3D CMS Logo

/data/doxygen/doxygen-1.7.3/gen/CMSSW_4_2_8/src/Geometry/TrackerCommonData/src/DDTIDRingAlgo.cc

Go to the documentation of this file.
00001 
00002 // File: DDTIDRingAlgo.cc
00003 // Description: Position n copies of detectors in alternate positions and
00004 //              also associated ICC's 
00005 // Em 17Sep07: Cool inserts moved to DDTIDModulePosAlgo.h 
00007 
00008 #include <cmath>
00009 #include <algorithm>
00010 
00011 #include "FWCore/MessageLogger/interface/MessageLogger.h"
00012 #include "DetectorDescription/Base/interface/DDutils.h"
00013 #include "DetectorDescription/Core/interface/DDCurrentNamespace.h"
00014 #include "DetectorDescription/Core/interface/DDSplit.h"
00015 #include "Geometry/TrackerCommonData/interface/DDTIDRingAlgo.h"
00016 #include "CLHEP/Units/GlobalPhysicalConstants.h"
00017 #include "CLHEP/Units/GlobalSystemOfUnits.h"
00018 
00019 
00020 DDTIDRingAlgo::DDTIDRingAlgo() {
00021   LogDebug("TIDGeom") << "DDTIDRingAlgo info: Creating an instance";
00022 }
00023 
00024 DDTIDRingAlgo::~DDTIDRingAlgo() {}
00025 
00026 void DDTIDRingAlgo::initialize(const DDNumericArguments & nArgs,
00027                                const DDVectorArguments & vArgs,
00028                                const DDMapArguments & ,
00029                                const DDStringArguments & sArgs,
00030                                const DDStringVectorArguments & vsArgs) {
00031 
00032   idNameSpace        = DDCurrentNamespace::ns();
00033   moduleName         = vsArgs["ModuleName"]; 
00034   iccName            = sArgs["ICCName"]; 
00035   DDName parentName = parent().name();
00036   LogDebug("TIDGeom") << "DDTIDRingAlgo debug: Parent " << parentName 
00037                       << "\tModule " << moduleName[0] << ", "
00038                       << moduleName[1] << "\tICC " << iccName 
00039                       << "\tNameSpace " << idNameSpace;
00040 
00041   number            = int (nArgs["Number"]);
00042   startAngle        = nArgs["StartAngle"];
00043   rModule           = nArgs["ModuleR"];
00044   zModule           = vArgs["ModuleZ"];
00045   rICC              = nArgs["ICCR"];
00046   sICC              = nArgs["ICCShift"];
00047   zICC              = vArgs["ICCZ"];
00048 
00049   LogDebug("TIDGeom") <<"DDTIDRingAlgo debug: Parameters for positioning--"
00050                       << " StartAngle " << startAngle/CLHEP::deg
00051                       << " Copy Numbers " << number << " Modules at R " 
00052                       << rModule << " Z " << zModule[0] << ", " << zModule[1] 
00053                       << " ICCs at R " << rICC << " Z " << zICC[0] << ", " 
00054                       << zICC[1]; 
00055 }
00056 
00057 void DDTIDRingAlgo::execute(DDCompactView& cpv) {
00058 
00059   double theta = 90.*CLHEP::deg;
00060   double phiy  = 0.*CLHEP::deg;
00061   double dphi  = CLHEP::twopi/number;
00062 
00063   DDName mother = parent().name();
00064   DDName module;
00065   DDName icc(DDSplit(iccName).first, DDSplit(iccName).second);
00066 
00067   //Loop over modules
00068   for (int i=0; i<number; i++) {
00069 
00070     //First the module
00071     double phiz = startAngle + i*dphi;
00072     double xpos = rModule*cos(phiz);
00073     double ypos = rModule*sin(phiz);
00074     double zpos, thetay, phix;
00075     if (i%2 == 0) {
00076       phix   = phiz + 90.*CLHEP::deg;
00077       thetay = 0*CLHEP::deg;
00078       zpos   = zModule[0];
00079       module = DDName(DDSplit(moduleName[0]).first, 
00080                       DDSplit(moduleName[0]).second);
00081     } else {
00082       phix   = phiz - 90.*CLHEP::deg;
00083       thetay = 180*CLHEP::deg;
00084       zpos   = zModule[1];
00085       module = DDName(DDSplit(moduleName[1]).first, 
00086                       DDSplit(moduleName[1]).second);
00087     }
00088     
00089     // stereo face inside toward structure, rphi face outside
00090     phix   = phix   - 180.*CLHEP::deg;
00091     thetay = thetay + 180.*CLHEP::deg;
00092     //
00093     
00094     DDTranslation trmod(xpos, ypos, zpos);
00095     double phideg = phiz/CLHEP::deg;
00096     DDRotation rotation;
00097     std::string rotstr = mother.name() + dbl_to_string(phideg*10.);
00098     rotation = DDRotation(DDName(rotstr, idNameSpace));
00099     if (!rotation) {
00100       LogDebug("TIDGeom") << "DDTIDRingAlgo test: Creating a new rotation "
00101                           << rotstr << "\t" << theta/CLHEP::deg << ", " 
00102                           << phix/CLHEP::deg << ", " << thetay/CLHEP::deg 
00103                           << ", " << phiy/CLHEP::deg << ", "
00104                           << theta/CLHEP::deg << ", " << phiz/CLHEP::deg;
00105       rotation = DDrot(DDName(rotstr, idNameSpace), theta, phix, thetay, phiy,
00106                        theta, phiz);
00107     }
00108   
00109    cpv.position(module, mother, i+1, trmod, rotation);
00110     LogDebug("TIDGeom") << "DDTIDRingAlgo test: " << module << " number "
00111                         << i+1 << " positioned in " << mother << " at "
00112                         << trmod << " with " << rotation;
00113 
00114     //Now the ICC
00115     if (i%2 == 0 ) {
00116       zpos = zICC[0];
00117       xpos = rICC*cos(phiz) + sICC*sin(phiz);
00118       ypos = rICC*sin(phiz) - sICC*cos(phiz);
00119     } else {
00120       zpos = zICC[1];
00121       xpos = rICC*cos(phiz) - sICC*sin(phiz);
00122       ypos = rICC*sin(phiz) + sICC*cos(phiz);
00123     }
00124     DDTranslation tricc(xpos, ypos, zpos);
00125    cpv.position(icc, mother, i+1, tricc, rotation);
00126     LogDebug("TIDGeom") << "DDTIDRingAlgo test: " << icc << " number " 
00127                         << i+1 << " positioned in " << mother << " at "
00128                         << tricc << " with " << rotation;
00129 
00130   }
00131 }