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/DDSolid.h"
00015 #include "DetectorDescription/Core/interface/DDMaterial.h"
00016 #include "DetectorDescription/Core/interface/DDCurrentNamespace.h"
00017 #include "DetectorDescription/Core/interface/DDSplit.h"
00018 #include "Geometry/HcalAlgo/interface/DDHCalForwardAlgo.h"
00019
00020 DDHCalForwardAlgo::DDHCalForwardAlgo(): number(0),size(0),type(0) {
00021 LogDebug("HCalGeom") << "DDHCalForwardAlgo info: Creating an instance";
00022 }
00023
00024 DDHCalForwardAlgo::~DDHCalForwardAlgo() {}
00025
00026
00027 void DDHCalForwardAlgo::initialize(const DDNumericArguments & nArgs,
00028 const DDVectorArguments & vArgs,
00029 const DDMapArguments & ,
00030 const DDStringArguments & sArgs,
00031 const DDStringVectorArguments & vsArgs) {
00032
00033 cellMat = sArgs["CellMaterial"];
00034 cellDx = nArgs["CellDx"];
00035 cellDy = nArgs["CellDy"];
00036 cellDz = nArgs["CellDz"];
00037 startY = nArgs["StartY"];
00038
00039 childName = vsArgs["Child"];
00040 number = dbl_to_int(vArgs["Number"]);
00041 size = dbl_to_int(vArgs["Size"]);
00042 type = dbl_to_int(vArgs["Type"]);
00043
00044 LogDebug("HCalGeom") << "DDHCalForwardAlgo debug: Cell material " << cellMat
00045 << "\tCell Size " << cellDx << ", " << cellDy << ", "
00046 << cellDz << "\tStarting Y " << startY << "\tChildren "
00047 << childName[0] << ", " << childName[1] << "\n"
00048 << " Cell positioning done for "
00049 << number.size() << " times";
00050 for (unsigned int i = 0; i < number.size(); i++)
00051 LogDebug("HCalGeom") << "\t" << i << " Number of children " << size[i]
00052 << " occurence " << number[i] << " first child index "
00053 << type[i];
00054
00055 idNameSpace = DDCurrentNamespace::ns();
00056 DDName parentName = parent().name();
00057 LogDebug("HCalGeom") << "DDHCalForwardAlgo debug: Parent " << parentName
00058 << " NameSpace " << idNameSpace;
00059 }
00060
00061 void DDHCalForwardAlgo::execute() {
00062
00063 LogDebug("HCalGeom") << "==>> Constructing DDHCalForwardAlgo...";
00064
00065 DDName parentName = parent().name();
00066 string idName = DDSplit(parentName).first;
00067 double ypos = startY;
00068 int box = 0;
00069
00070 for (unsigned int i=0; i<number.size(); i++) {
00071 double dx = cellDx*size[i];
00072 int indx = type[i];
00073 for (int j=0; j<number[i]; j++) {
00074 box++;
00075 string name = idName + dbl_to_string(box);
00076 DDSolid solid = DDSolidFactory::box(DDName(name, idNameSpace),
00077 dx, cellDy, cellDz);
00078 LogDebug("HCalGeom") << "DDHCalForwardAlgo test: "
00079 << DDName(name, idNameSpace) << " Box made of "
00080 << cellMat << " of Size " << dx << ", " << cellDy
00081 << ", " << cellDz;
00082
00083 DDName matname(DDSplit(cellMat).first, DDSplit(cellMat).second);
00084 DDMaterial matter(matname);
00085 DDLogicalPart genlogic(solid.ddname(), matter, solid);
00086
00087 DDTranslation r0(0.0, ypos, 0.0);
00088 DDRotation rot;
00089 DDpos(solid.ddname(), parentName, box, r0, rot);
00090 LogDebug("HCalGeom") << "DDHCalForwardAlgo test: " << solid.ddname()
00091 << " number " << box << " positioned in "
00092 << parentName << " at " << r0 << " with " << rot;
00093
00094 DDName child(DDSplit(childName[indx]).first,
00095 DDSplit(childName[indx]).second);
00096 double xpos = -dx + cellDx;
00097 ypos += 2*cellDy;
00098 indx = 1 - indx;
00099
00100 for (int k=0; k<size[i]; k++) {
00101 DDTranslation r1(xpos, 0.0, 0.0);
00102 DDpos (child, solid.ddname(), k+1, r1, rot);
00103 LogDebug("HCalGeom") << "DDHCalForwardAlgo test: " << child
00104 << " number " << k+1 << " positioned in "
00105 << solid.ddname() << " at " << r1 << " with "
00106 << rot;
00107 xpos += 2*cellDx;
00108 }
00109 }
00110 }
00111 LogDebug("HCalGeom") << "<<== End of DDHCalForwardAlgo construction ...";
00112 }