CMS 3D CMS Logo

/afs/cern.ch/work/a/aaltunda/public/www/CMSSW_5_3_14/src/Geometry/TrackerCommonData/plugins/DDTrackerZPosAlgo.cc

Go to the documentation of this file.
00001 
00002 // File: DDTrackerZPosAlgo.cc
00003 // Description: Position n copies at given z-values
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/plugins/DDTrackerZPosAlgo.h"
00013 #include "CLHEP/Units/GlobalPhysicalConstants.h"
00014 #include "CLHEP/Units/GlobalSystemOfUnits.h"
00015 
00016 
00017 DDTrackerZPosAlgo::DDTrackerZPosAlgo() {
00018   LogDebug("TrackerGeom") <<"DDTrackerZPosAlgo info: Creating an instance";
00019 }
00020 
00021 DDTrackerZPosAlgo::~DDTrackerZPosAlgo() {}
00022 
00023 void DDTrackerZPosAlgo::initialize(const DDNumericArguments & nArgs,
00024                                    const DDVectorArguments & vArgs,
00025                                    const DDMapArguments & ,
00026                                    const DDStringArguments & sArgs,
00027                                    const DDStringVectorArguments & vsArgs) {
00028 
00029   startCopyNo = int(nArgs["StartCopyNo"]);
00030   incrCopyNo  = int(nArgs["IncrCopyNo"]);
00031   zvec        = vArgs["ZPositions"];
00032   rotMat      = vsArgs["Rotations"];
00033   
00034   idNameSpace = DDCurrentNamespace::ns();
00035   childName   = sArgs["ChildName"]; 
00036   DDName parentName = parent().name();
00037   LogDebug("TrackerGeom") << "DDTrackerZPosAlgo debug: Parent " << parentName 
00038                           << "\tChild " << childName << " NameSpace " 
00039                           << idNameSpace << "\tCopyNo (Start/Increment) " 
00040                           << startCopyNo << ", " << incrCopyNo << "\tNumber " 
00041                           << zvec.size();
00042   for (int i = 0; i < (int)(zvec.size()); i++) {
00043     LogDebug("TrackerGeom") << "\t[" << i << "]\tZ = " << zvec[i] 
00044                             << ", Rot.Matrix = " << rotMat[i];
00045   }
00046 }
00047 
00048 void DDTrackerZPosAlgo::execute(DDCompactView& cpv) {
00049 
00050   int    copy   = startCopyNo;
00051   DDName mother = parent().name();
00052   DDName child(DDSplit(childName).first, DDSplit(childName).second);
00053 
00054   for (int i=0; i<(int)(zvec.size()); i++) {
00055         
00056     DDTranslation tran(0, 0, zvec[i]);
00057     std::string rotstr = DDSplit(rotMat[i]).first;
00058     DDRotation rot;
00059     if (rotstr != "NULL") {
00060       std::string rotns  = DDSplit(rotMat[i]).second;
00061       rot = DDRotation(DDName(rotstr, rotns));
00062     }
00063    cpv.position(child, mother, copy, tran, rot);
00064     LogDebug("TrackerGeom") << "DDTrackerZPosAlgo test: " << child <<" number "
00065                             << copy << " positioned in " << mother << " at "
00066                             << tran << " with " << rot;
00067     copy += incrCopyNo;
00068   }
00069 }