CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_2_7_hltpatch2/src/Geometry/HcalAlgo/plugins/DDHCalTBZposAlgo.cc

Go to the documentation of this file.
00001 
00002 // File: DDHCalTBZposAlgo.cc
00003 // Description: Position inside the mother by shifting along Z given by eta
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/DDCurrentNamespace.h"
00014 #include "DetectorDescription/Core/interface/DDSplit.h"
00015 #include "Geometry/HcalAlgo/plugins/DDHCalTBZposAlgo.h"
00016 #include "CLHEP/Units/GlobalSystemOfUnits.h"
00017 
00018 DDHCalTBZposAlgo::DDHCalTBZposAlgo() {
00019   LogDebug("HCalGeom") << "DDHCalTBZposAlgo test: Creating an instance";
00020 }
00021 
00022 DDHCalTBZposAlgo::~DDHCalTBZposAlgo() {}
00023 
00024 void DDHCalTBZposAlgo::initialize(const DDNumericArguments & nArgs,
00025                                   const DDVectorArguments & ,
00026                                   const DDMapArguments & ,
00027                                   const DDStringArguments & sArgs,
00028                                   const DDStringVectorArguments & ) {
00029 
00030   eta        = nArgs["Eta"];
00031   theta      = 2.0*atan(exp(-eta));
00032   shiftX     = nArgs["ShiftX"];
00033   shiftY     = nArgs["ShiftY"];
00034   zoffset    = nArgs["Zoffset"];
00035   dist       = nArgs["Distance"];
00036   tilt       = nArgs["TiltAngle"];
00037   copyNumber = int (nArgs["Number"]);
00038   LogDebug("HCalGeom") << "DDHCalTBZposAlgo debug: Parameters for position"
00039                        << "ing--" << " Eta " << eta << "\tTheta " 
00040                        << theta/CLHEP::deg << "\tShifts " << shiftX << ", " 
00041                        << shiftY  << " along x, y axes; \tZoffest " << zoffset
00042                        << "\tRadial Distance " << dist << "\tTilt angle "
00043                        << tilt/CLHEP::deg << "\tcopyNumber " << copyNumber;
00044 
00045   idNameSpace = DDCurrentNamespace::ns();
00046   childName   = sArgs["ChildName"]; 
00047   DDName parentName = parent().name(); 
00048   LogDebug("HCalGeom") << "DDHCalTBZposAlgo debug: Parent " << parentName
00049                        << "\tChild " << childName << " NameSpace "
00050                        << idNameSpace;
00051 }
00052 
00053 void DDHCalTBZposAlgo::execute(DDCompactView& cpv) {
00054 
00055   DDName mother = parent().name();
00056   DDName child(DDSplit(childName).first, DDSplit(childName).second);
00057  
00058   double thetax = 90.*CLHEP::deg - theta;
00059   double z      = zoffset + dist*tan(thetax);
00060   double x      = shiftX - shiftY*sin(tilt);
00061   double y      = shiftY*cos(tilt);
00062   DDTranslation tran(x,y,z);
00063   DDRotation rot;
00064   double tiltdeg = tilt/CLHEP::deg;
00065   int    itilt   = int(tiltdeg+0.1);
00066   if (itilt != 0) {
00067     std::string rotstr = "R";
00068     if (tiltdeg < 100) rotstr = "R0"; 
00069     rotstr = rotstr + dbl_to_string(tiltdeg);
00070     rot    = DDRotation(DDName(rotstr, idNameSpace)); 
00071     if (!rot) {
00072       LogDebug("HCalGeom") << "DDHCalAngular test: Creating a new rotation "
00073                            << DDName(rotstr,idNameSpace) << "\t90, " << tiltdeg
00074                            << ", 90, " << (tiltdeg+90) << ", 0, 0";
00075       rot = DDrot(DDName(rotstr, idNameSpace), 90*CLHEP::deg, tilt, 
00076                   90*CLHEP::deg, (90*CLHEP::deg+tilt), 0.0,  0.0);
00077     }
00078   }
00079  cpv.position(child, mother, copyNumber, tran, rot);
00080   LogDebug("HCalGeom") << "DDHCalTBZposAlgo test: " << child << " number " 
00081                        << copyNumber << " positioned in " << mother
00082                        << " at " << tran << " with " << rot;
00083 }