CMS 3D CMS Logo

DDHCalTestBeamAlgo.cc

Go to the documentation of this file.
00001 
00002 // File: DDHCalTestBeamAlgo.cc
00003 // Description: Position inside the mother according to (eta,phi) 
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/DDPosPart.h"
00012 #include "DetectorDescription/Core/interface/DDLogicalPart.h"
00013 #include "DetectorDescription/Core/interface/DDCurrentNamespace.h"
00014 #include "Geometry/HcalAlgo/interface/DDHCalTestBeamAlgo.h"
00015 #include "CLHEP/Units/SystemOfUnits.h"
00016 
00017 DDHCalTestBeamAlgo::DDHCalTestBeamAlgo() {
00018   LogDebug("HCalGeom") << "DDHCalTestBeamAlgo test: Creating an instance";
00019 }
00020 
00021 DDHCalTestBeamAlgo::~DDHCalTestBeamAlgo() {}
00022 
00023 void DDHCalTestBeamAlgo::initialize(const DDNumericArguments & nArgs,
00024                                     const DDVectorArguments & ,
00025                                     const DDMapArguments & ,
00026                                     const DDStringArguments & sArgs,
00027                                     const DDStringVectorArguments & ) {
00028 
00029   eta        = nArgs["Eta"];
00030   theta      = 2.0*atan(exp(-eta));
00031   phi        = nArgs["Phi"];
00032   distance   = nArgs["Dist"];
00033   distanceZ  = nArgs["DistZ"];
00034   dz         = nArgs["Dz"];
00035   copyNumber = int (nArgs["Number"]);
00036   dist       = (distance+distanceZ/sin(theta));
00037   LogDebug("HCalGeom") << "DDHCalTestBeamAlgo debug: Parameters for position"
00038                        << "ing--" << " Eta " << eta << "\tPhi " << phi/deg 
00039                        << "\tTheta " << theta/deg << "\tDistance " << distance
00040                        << "/" << distanceZ << "/" << dist << "\tDz " << dz 
00041                        << "\tcopyNumber " << copyNumber;
00042 
00043   idNameSpace = DDCurrentNamespace::ns();
00044   childName   = sArgs["ChildName"]; 
00045   DDName parentName = parent().name(); 
00046   LogDebug("HCalGeom") << "DDHCalTestBeamAlgo debug: Parent " << parentName
00047                        << "\tChild " << childName << " NameSpace "
00048                        << idNameSpace;
00049 }
00050 
00051 void DDHCalTestBeamAlgo::execute() {
00052 
00053   double thetax = 90.*deg + theta;
00054   double sthx   = sin(thetax);
00055   if (abs(sthx)>1.e-12) sthx = 1./sthx;
00056   else                  sthx = 1.;
00057   double phix   = atan2(sthx*cos(theta)*sin(phi),sthx*cos(theta)*cos(phi));
00058   double thetay = 90.*deg;
00059   double phiy   = 90.*deg + phi;
00060   double thetaz = theta;
00061   double phiz   = phi;
00062   
00063   DDRotation rotation;
00064   string rotstr = childName;
00065   LogDebug("HCalGeom") << "DDHCalTestBeamAlgo test: Creating a new rotation "
00066                        << rotstr << "\t" << thetax/deg << "," << phix/deg 
00067                        << "," << thetay/deg << "," << phiy/deg << "," 
00068                        << thetaz/deg <<"," << phiz/deg;
00069   rotation = DDrot(DDName(rotstr, idNameSpace), thetax, phix, thetay, phiy,
00070                    thetaz, phiz);
00071         
00072   double r    = dist*sin(theta);
00073   double xpos = r*cos(phi);
00074   double ypos = r*sin(phi);
00075   double zpos = dist*cos(theta);
00076   DDTranslation tran(xpos, ypos, zpos);
00077   
00078   DDName parentName = parent().name(); 
00079   DDpos (DDName(childName,idNameSpace), parentName,copyNumber, tran,rotation);
00080   LogDebug("HCalGeom") << "DDHCalTestBeamAlgo test: " 
00081                        << DDName(childName, idNameSpace) << " number " 
00082                        << copyNumber << " positioned in " << parentName 
00083                        << " at " << tran << " with " << rotation;
00084 
00085   xpos = (dist-dz)*sin(theta)*cos(phi);
00086   ypos = (dist-dz)*sin(theta)*sin(phi);
00087   zpos = (dist-dz)*cos(theta);
00088 
00089   edm::LogInfo("HCalGeom") << "DDHCalTestBeamAlgo: Suggested Beam position "
00090                            << "(" << xpos << ", " << ypos << ", " << zpos 
00091                            << ") and (dist, eta, phi) = (" << (dist-dz) << ", "
00092                            << eta << ", " << phi << ")";
00093 }

Generated on Tue Jun 9 17:37:30 2009 for CMSSW by  doxygen 1.5.4