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/Core/interface/DDCurrentNamespace.h"
00011 #include "DetectorDescription/Core/interface/DDSplit.h"
00012 #include "Geometry/HcalAlgo/plugins/DDHCalLinearXY.h"
00013
00014
00015 DDHCalLinearXY::DDHCalLinearXY() {
00016 LogDebug("HCalGeom") <<"DDHCalLinearXY info: Creating an instance";
00017 }
00018
00019 DDHCalLinearXY::~DDHCalLinearXY() {}
00020
00021 void DDHCalLinearXY::initialize(const DDNumericArguments & nArgs,
00022 const DDVectorArguments & vArgs,
00023 const DDMapArguments & ,
00024 const DDStringArguments & sArgs,
00025 const DDStringVectorArguments & vsArgs) {
00026
00027 numberX = int(nArgs["NumberX"]);
00028 deltaX = nArgs["DeltaX"];
00029 numberY = int(nArgs["NumberY"]);
00030 deltaY = nArgs["DeltaY"];
00031 centre = vArgs["Center"];
00032
00033 idNameSpace = DDCurrentNamespace::ns();
00034 childName = vsArgs["Child"];
00035 DDName parentName = parent().name();
00036 LogDebug("HCalGeom") << "DDHCalLinearXY debug: Parent " << parentName
00037 << "\twith " << childName.size() << " children";
00038 for (unsigned int i=0; i<childName.size(); ++i)
00039 LogDebug("HCalGeom") << "DDHCalLinearXY debug: Child[" << i << "] = "
00040 << childName[i];
00041 LogDebug("HCalGeom") << "DDHCalLinearXY debug: NameSpace "
00042 << idNameSpace << "\tNumber along X/Y " << numberX
00043 << "/" << numberY << "\tDelta along X/Y " << deltaX
00044 << "/" << deltaY << "\tCentre " << centre[0] << ", "
00045 << centre[1] << ", " << centre[2];
00046 }
00047
00048 void DDHCalLinearXY::execute(DDCompactView& cpv) {
00049
00050 DDName mother = parent().name();
00051 DDName child;
00052 DDRotation rot;
00053 double xoff = centre[0] - (numberX-1)*deltaX/2.;
00054 double yoff = centre[1] - (numberY-1)*deltaY/2.;
00055 int copy = 0;
00056
00057 for (int i=0; i<numberX; i++) {
00058 for (int j=0; j<numberY; j++) {
00059
00060 DDTranslation tran(xoff+i*deltaX,yoff+j*deltaY,centre[2]);
00061 bool place = true;
00062 unsigned int k = copy;
00063 if (childName.size() == 1) k = 0;
00064 if (k < childName.size() && (childName[k] != " " && childName[k] != "Null")) {
00065 child = DDName(DDSplit(childName[k]).first, DDSplit(childName[k]).second);
00066 } else {
00067 place = false;
00068 }
00069 copy++;
00070 if (place) {
00071 cpv.position(child, mother, copy, tran, rot);
00072 LogDebug("HCalGeom") << "DDHCalLinearXY test: " << child
00073 << " number " << copy << " positioned in "
00074 << mother << " at " << tran << " with " << rot;
00075 } else {
00076 LogDebug("HCalGeom") << "DDHCalLinearXY test: No child placed for ["
00077 << copy << "]";
00078 }
00079 }
00080 }
00081 }