CMS 3D CMS Logo

DDTrackerLinear.cc

Go to the documentation of this file.
00001 
00002 // File: DDTrackerLinear.cc
00003 // Description: Position n copies at given intervals along an axis
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/DDCurrentNamespace.h"
00012 #include "DetectorDescription/Core/interface/DDSplit.h"
00013 #include "Geometry/TrackerCommonData/interface/DDTrackerLinear.h"
00014 #include "CLHEP/Units/PhysicalConstants.h"
00015 #include "CLHEP/Units/SystemOfUnits.h"
00016 
00017 
00018 DDTrackerLinear::DDTrackerLinear() : startcn(1), incrcn(1) {
00019   LogDebug("TrackerGeom") << "DDTrackerLinear info: Creating an instance";
00020 }
00021 
00022 DDTrackerLinear::~DDTrackerLinear() {}
00023 
00024 void DDTrackerLinear::initialize(const DDNumericArguments & nArgs,
00025                                  const DDVectorArguments & vArgs,
00026                                  const DDMapArguments & ,
00027                                  const DDStringArguments & sArgs,
00028                                  const DDStringVectorArguments &) {
00029 
00030   number    = int(nArgs["Number"]);
00031   theta     = nArgs["Theta"];
00032   phi       = nArgs["Phi"];
00033   offset    = nArgs["Offset"];
00034   delta     = nArgs["Delta"];
00035   centre    = vArgs["Center"];
00036   rotMat    = sArgs["Rotation"];
00037   if ( nArgs.find("StartCopyNo") != nArgs.end() ) {
00038     startcn = size_t(nArgs["StartCopyNo"]);
00039   }
00040   if ( nArgs.find("IncrCopyNo") != nArgs.end() ) {
00041     incrcn = int(nArgs["IncrCopyNo"]);
00042   }
00043   
00044   idNameSpace = DDCurrentNamespace::ns();
00045   childName   = sArgs["ChildName"]; 
00046   DDName parentName = parent().name();
00047   LogDebug("TrackerGeom") << "DDTrackerLinear debug: Parent " << parentName 
00048                           << "\tChild " << childName << " NameSpace " 
00049                           << idNameSpace << "\tNumber " << number 
00050                           << "\tAxis (theta/phi) " << theta/deg << ", "
00051                           << phi/deg << "\t(Offset/Delta) " << offset << ", " 
00052                           << delta << "\tCentre " << centre[0] << ", " 
00053                           << centre[1] << ", " << centre[2] << "\tRotation "
00054                           << rotMat;
00055 }
00056 
00057 void DDTrackerLinear::execute() {
00058 
00059   DDName mother = parent().name();
00060   DDName child(DDSplit(childName).first, DDSplit(childName).second);
00061   DDTranslation direction(sin(theta)*cos(phi),sin(theta)*sin(phi),cos(theta));
00062   DDTranslation base(centre[0],centre[1],centre[2]);
00063   std::string rotstr = DDSplit(rotMat).first;
00064   DDRotation rot;
00065   if (rotstr != "NULL") {
00066     std::string rotns  = DDSplit(rotMat).second;
00067     rot = DDRotation(DDName(rotstr, rotns));
00068   }
00069   int ci = startcn;
00070   for (int i=0; i<number; i++) {
00071         
00072     DDTranslation tran = base + (offset + double(i)*delta)*direction;
00073     DDpos (child, mother, ci, tran, rot);
00074     LogDebug("TrackerGeom") << "DDTrackerLinear test: " << child << " number "
00075                             << ci << " positioned in " << mother << " at "
00076                             << tran << " with " << rot;
00077     ++ci;
00078   }
00079 }

Generated on Tue Jun 9 17:37:33 2009 for CMSSW by  doxygen 1.5.4