CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_4_1_8_patch12/src/Geometry/HcalAlgo/src/DDHCalForwardAlgo.cc

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