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/Core/interface/DDPosPart.h"
00012 #include "DetectorDescription/Core/interface/DDLogicalPart.h"
00013 #include "DetectorDescription/Core/interface/DDCurrentNamespace.h"
00014 #include "Geometry/HcalAlgo/interface/DDHCalXtalAlgo.h"
00015 #include "CLHEP/Units/SystemOfUnits.h"
00016
00017 DDHCalXtalAlgo::DDHCalXtalAlgo() {
00018 LogDebug("HCalGeom") << "DDHCalXtalAlgo info: Creating an instance";
00019 }
00020
00021 DDHCalXtalAlgo::~DDHCalXtalAlgo() {}
00022
00023 void DDHCalXtalAlgo::initialize(const DDNumericArguments & nArgs,
00024 const DDVectorArguments & ,
00025 const DDMapArguments & ,
00026 const DDStringArguments & sArgs,
00027 const DDStringVectorArguments & vsArgs) {
00028
00029 radius = nArgs["Radius"];
00030 offset = nArgs["Offset"];
00031 dx = nArgs["Dx"];
00032 dz = nArgs["Dz"];
00033 angwidth = nArgs["AngWidth"];
00034 iaxis = int (nArgs["Axis"]);
00035 names = vsArgs["Names"];
00036
00037 LogDebug("HCalGeom") << "DDHCalXtalAlgo debug: Parameters for positioning:: "
00038 << "Axis " << iaxis << "\tRadius " << radius
00039 << "\tOffset " << offset << "\tDx " << dx << "\tDz "
00040 << dz << "\tAngWidth " << angwidth/deg << "\tNumbers "
00041 << names.size();
00042 for (unsigned int i = 0; i < names.size(); i++)
00043 LogDebug("HCalGeom") << "\tnames[" << i << "] = " << names[i];
00044
00045 idNameSpace = DDCurrentNamespace::ns();
00046 idName = sArgs["ChildName"];
00047 DDName parentName = parent().name();
00048 LogDebug("HCalGeom") << "DDHCalXtalAlgo debug: Parent " << parentName
00049 << "\tChild " << idName << " NameSpace " << idNameSpace;
00050 }
00051
00052 void DDHCalXtalAlgo::execute() {
00053
00054 double theta[3], phi[3], pos[3];
00055 phi[0] = 0;
00056 phi[1] = 90*deg;
00057 theta[1-iaxis] = 90*deg;
00058 pos[1-iaxis] = 0;
00059 int number = (int)(names.size());
00060 for (int i=0; i<number; i++) {
00061 double angle = 0.5*angwidth*(2*i+1-number);
00062 theta[iaxis] = 90*deg + angle;
00063 if (angle>0) {
00064 theta[2] = angle;
00065 phi[2] = 90*iaxis*deg;
00066 } else {
00067 theta[2] =-angle;
00068 phi[2] = 90*(2-3*iaxis)*deg;
00069 }
00070 pos[iaxis] = angle*(dz+radius);
00071 pos[2] = dx*abs(sin(angle)) + offset;
00072
00073 DDRotation rotation;
00074 string rotstr = names[i];
00075 DDTranslation tran(pos[0], pos[1], pos[2]);
00076 DDName parentName = parent().name();
00077
00078 if (abs(angle) > 0.01*deg) {
00079 LogDebug("HCalGeom") << "DDHCalXtalAlgo test: Creating a new rotation "
00080 << rotstr << "\t" << theta[0]/deg << ","
00081 << phi[0]/deg << "," << theta[1]/deg << ","
00082 << phi[1]/deg << "," << theta[2]/deg << ","
00083 << phi[2]/deg;
00084 rotation = DDrot(DDName(rotstr, idNameSpace), theta[0], phi[0], theta[1],
00085 phi[1], theta[2], phi[2]);
00086 }
00087 DDpos (DDName(idName, idNameSpace), parentName, i+1, tran, rotation);
00088 LogDebug("HCalGeom") << "DDHCalXtalAlgo test: "
00089 << DDName(idName,idNameSpace) << " number " << i+1
00090 << " positioned in " << parentName << " at " << tran
00091 << " with " << rotation;
00092 }
00093 }