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