00001
00002
00003
00005
00006 #include <cmath>
00007 #include <algorithm>
00008
00009 namespace std{} using namespace std;
00010 #include "FWCore/MessageLogger/interface/MessageLogger.h"
00011 #include "DetectorDescription/Base/interface/DDutils.h"
00012 #include "DetectorDescription/Core/interface/DDPosPart.h"
00013 #include "DetectorDescription/Core/interface/DDLogicalPart.h"
00014 #include "DetectorDescription/Core/interface/DDCurrentNamespace.h"
00015 #include "DetectorDescription/Core/interface/DDSplit.h"
00016 #include "Geometry/HcalAlgo/interface/DDHCalTBZposAlgo.h"
00017 #include "CLHEP/Units/SystemOfUnits.h"
00018
00019 DDHCalTBZposAlgo::DDHCalTBZposAlgo() {
00020 LogDebug("HCalGeom") << "DDHCalTBZposAlgo test: Creating an instance";
00021 }
00022
00023 DDHCalTBZposAlgo::~DDHCalTBZposAlgo() {}
00024
00025 void DDHCalTBZposAlgo::initialize(const DDNumericArguments & nArgs,
00026 const DDVectorArguments & ,
00027 const DDMapArguments & ,
00028 const DDStringArguments & sArgs,
00029 const DDStringVectorArguments & ) {
00030
00031 eta = nArgs["Eta"];
00032 theta = 2.0*atan(exp(-eta));
00033 shiftX = nArgs["ShiftX"];
00034 shiftY = nArgs["ShiftY"];
00035 zoffset = nArgs["Zoffset"];
00036 dist = nArgs["Distance"];
00037 tilt = nArgs["TiltAngle"];
00038 copyNumber = int (nArgs["Number"]);
00039 LogDebug("HCalGeom") << "DDHCalTBZposAlgo debug: Parameters for position"
00040 << "ing--" << " Eta " << eta << "\tTheta " << theta/deg
00041 << "\tShifts " << shiftX << ", " << shiftY
00042 << " along x, y axes; \tZoffest " << zoffset
00043 << "\tRadial Distance " << dist << "\tTilt angle "
00044 << tilt/deg << "\tcopyNumber " << copyNumber;
00045
00046 idNameSpace = DDCurrentNamespace::ns();
00047 childName = sArgs["ChildName"];
00048 DDName parentName = parent().name();
00049 LogDebug("HCalGeom") << "DDHCalTBZposAlgo debug: Parent " << parentName
00050 << "\tChild " << childName << " NameSpace "
00051 << idNameSpace;
00052 }
00053
00054 void DDHCalTBZposAlgo::execute() {
00055
00056 DDName mother = parent().name();
00057 DDName child(DDSplit(childName).first, DDSplit(childName).second);
00058
00059 double thetax = 90.*deg - theta;
00060 double z = zoffset + dist*tan(thetax);
00061 double x = shiftX - shiftY*sin(tilt);
00062 double y = shiftY*cos(tilt);
00063 DDTranslation tran(x,y,z);
00064 DDRotation rot;
00065 double tiltdeg = tilt/deg;
00066 int itilt = int(tiltdeg+0.1);
00067 if (itilt != 0) {
00068 std::string rotstr = "R";
00069 if (tiltdeg < 100) rotstr = "R0";
00070 rotstr = rotstr + dbl_to_string(tiltdeg);
00071 rot = DDRotation(DDName(rotstr, idNameSpace));
00072 if (!rot) {
00073 LogDebug("HCalGeom") << "DDHCalAngular test: Creating a new rotation "
00074 << DDName(rotstr,idNameSpace) << "\t90, " << tiltdeg
00075 << ", 90, " << (tiltdeg+90) << ", 0, 0";
00076 rot = DDrot(DDName(rotstr, idNameSpace), 90*deg, tilt,
00077 90*deg, (90*deg+tilt), 0*deg, 0*deg);
00078 }
00079 }
00080 DDpos (child, mother, copyNumber, tran, rot);
00081 LogDebug("HCalGeom") << "DDHCalTBZposAlgo test: " << child << " number "
00082 << copyNumber << " positioned in " << mother
00083 << " at " << tran << " with " << rot;
00084 }