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/Base/interface/DDutils.h"
00011 #include "DetectorDescription/Core/interface/DDCurrentNamespace.h"
00012 #include "DetectorDescription/Core/interface/DDSplit.h"
00013 #include "Geometry/TrackerCommonData/interface/DDTECOptoHybAlgo.h"
00014 #include "CLHEP/Units/GlobalPhysicalConstants.h"
00015 #include "CLHEP/Units/GlobalSystemOfUnits.h"
00016
00017
00018 DDTECOptoHybAlgo::DDTECOptoHybAlgo(): angles(0) {
00019 LogDebug("TECGeom") << "DDTECOptoHybAlgo info: Creating an instance";
00020 }
00021
00022 DDTECOptoHybAlgo::~DDTECOptoHybAlgo() {}
00023
00024 void DDTECOptoHybAlgo::initialize(const DDNumericArguments & nArgs,
00025 const DDVectorArguments & vArgs,
00026 const DDMapArguments & ,
00027 const DDStringArguments & sArgs,
00028 const DDStringVectorArguments & ) {
00029
00030 idNameSpace = DDCurrentNamespace::ns();
00031 childName = sArgs["ChildName"];
00032
00033 DDName parentName = parent().name();
00034
00035 LogDebug("TECGeom") << "DDTECOptoHybAlgo debug: Parent " << parentName
00036 << " Child " << childName << " NameSpace " <<idNameSpace;
00037
00038 optoHeight = nArgs["OptoHeight"];
00039 optoWidth = nArgs["OptoWidth"];
00040 rpos = nArgs["Rpos"];
00041 zpos = nArgs["Zpos"];
00042 startCopyNo = int (nArgs["StartCopyNo"]);
00043 angles = vArgs["Angles"];
00044
00045 LogDebug("TECGeom") << "DDTECOptoHybAlgo debug: Height of the Hybrid "
00046 << optoHeight << " and Width " << optoWidth
00047 <<"Rpos " << rpos << " Zpos " << zpos
00048 << " StartCopyNo " << startCopyNo << " Number "
00049 << angles.size();
00050
00051 for (int i = 0; i < (int)(angles.size()); i++)
00052 LogDebug("TECGeom") << "\tAngles[" << i << "] = " << angles[i];
00053
00054 }
00055
00056 void DDTECOptoHybAlgo::execute(DDCompactView& cpv) {
00057
00058 LogDebug("TECGeom") << "==>> Constructing DDTECOptoHybAlgo...";
00059
00060 DDName mother = parent().name();
00061 DDName child = DDName(DDSplit(childName).first, DDSplit(childName).second);
00062
00063
00064 rpos += optoHeight/2;
00065 int copyNo = startCopyNo;
00066 for (int i = 0; i < (int)(angles.size()); i++) {
00067 double phix = -angles.at(i);
00068
00069 phix += asin(optoWidth/2/rpos);
00070 double xpos = rpos * cos(phix);
00071 double ypos = rpos * sin(phix);
00072 DDTranslation tran(xpos, ypos, zpos);
00073
00074 DDRotation rotation;
00075 double phiy = phix + 90.*CLHEP::deg;
00076 double phideg = phix/CLHEP::deg;
00077 if (phideg != 0) {
00078 std::string rotstr= DDSplit(childName).first+dbl_to_string(phideg*1000.);
00079 rotation = DDRotation(DDName(rotstr, idNameSpace));
00080 if (!rotation) {
00081 double theta = 90.*CLHEP::deg;
00082 LogDebug("TECGeom") << "DDTECOptoHybAlgo test: Creating a new "
00083 << "rotation: " << rotstr << "\t90., "
00084 << phix/CLHEP::deg << ", 90.," << phiy/CLHEP::deg
00085 << ", 0, 0";
00086 rotation = DDrot(DDName(rotstr, idNameSpace), theta, phix, theta, phiy,
00087 0., 0.);
00088 }
00089 }
00090
00091 cpv.position(child, mother, copyNo, tran, rotation);
00092 LogDebug("TECGeom") << "DDTECOptoHybAlgo test " << child << " number "
00093 << copyNo << " positioned in " << mother << " at "
00094 << tran << " with " << rotation;
00095 copyNo++;
00096 }
00097
00098 LogDebug("TECGeom") << "<<== End of DDTECOptoHybAlgo construction ...";
00099 }