CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_4_1_8_patch9/src/Geometry/TrackerCommonData/src/DDTrackerXYZPosAlgo.cc

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