Go to the documentation of this file.00001
00002
00003
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 "SLHCUpgradeSimulations/Geometry/interface/DDPixBarStackLinear.h"
00013 #include "CLHEP/Units/PhysicalConstants.h"
00014 #include "CLHEP/Units/SystemOfUnits.h"
00015
00016
00017 DDPixBarStackLinear::DDPixBarStackLinear() {
00018 LogDebug("TrackerGeom") << "DDPixBarStackLinear info: Creating an instance";
00019 }
00020
00021 DDPixBarStackLinear::~DDPixBarStackLinear() {}
00022
00023 void DDPixBarStackLinear::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 stackoffset = nArgs["StackOffset"];
00037 stackoffsetT= int(nArgs["StackOffsetT"]);
00038 zoffset = nArgs["ZOffset"];
00039
00040 idNameSpace = DDCurrentNamespace::ns();
00041 childName = sArgs["ChildName"];
00042 DDName parentName = parent().name();
00043 LogDebug("TrackerGeom") << "DDPixBarStackLinear debug: Parent " << parentName
00044 << "\tChild " << childName << " NameSpace "
00045 << idNameSpace << "\tNumber " << number
00046 << "\tAxis (theta/phi) " << theta/CLHEP::deg << ", "
00047 << phi/CLHEP::deg << "\t(Offset/Delta) " << offset << ", "
00048 << delta << "\tCentre " << centre[0] << ", "
00049 << centre[1] << ", " << centre[2] << "\tRotation "
00050 << rotMat;
00051 }
00052
00053 void DDPixBarStackLinear::execute(DDCompactView& cpv) {
00054
00055 DDName mother = parent().name();
00056 DDName child(DDSplit(childName).first, DDSplit(childName).second);
00057 DDTranslation direction(sin(theta)*cos(phi),sin(theta)*sin(phi),cos(theta));
00058 DDTranslation base(centre[0],centre[1],centre[2]);
00059 DDTranslation zbase(centre[0],zoffset,centre[2]);
00060 std::string rotstr = DDSplit(rotMat).first;
00061 DDRotation rot;
00062 if (rotstr != "NULL") {
00063 std::string rotns = DDSplit(rotMat).second;
00064 rot = DDRotation(DDName(rotstr, rotns));
00065 }
00066
00067 for (int i=0; i<(number/2); i++) {
00068
00069 if((stackoffset!=0.0)&&(i!=0)) {
00070 if(i%stackoffsetT==0) offset+=stackoffset;
00071 }
00072
00073 DDTranslation tran = base + (offset + double(i)*delta)*direction;
00074 cpv.position (child, mother, 2*i+1, tran, rot);
00075 LogDebug("TrackerGeom") << "DDPixBarStackLinear test: " << child << " number "
00076 << 2*i+1 << " positioned in " << mother << " at "
00077 << tran << " with " << rot;
00078
00079 DDTranslation tran2 = base - (offset + double(i)*delta)*direction;
00080 cpv.position (child, mother, 2*i+2, tran2, rot);
00081 LogDebug("TrackerGeom") << "DDPixBarStackLinear test: " << child << " number "
00082 << 2*i+2 << " positioned in " << mother << " at "
00083 << tran << " with " << rot;
00084
00085 if(zoffset!=0.0){
00086 if((i+1)!=number){
00087 i++;
00088 DDTranslation tran3 = zbase + (offset + double(i)*delta)*direction;
00089 cpv.position (child, mother, 2*i+1, tran3, rot);
00090 LogDebug("TrackerGeom") << "DDPixBarStackLinear test: " << child << " number "
00091 << 2*i+1 << " positioned in " << mother << " at "
00092 << tran << " with " << rot;
00093
00094 DDTranslation tran4 = zbase - (offset + double(i)*delta)*direction;
00095 cpv.position (child, mother, 2*i+2, tran4, rot);
00096 LogDebug("TrackerGeom") << "DDPixBarStackLinear test: " << child << " number "
00097 << 2*i+2 << " positioned in " << mother << " at "
00098 << tran << " with " << rot;
00099
00100 }
00101 }
00102
00103 }
00104 }