CMS 3D CMS Logo

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