CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_6_1_1/src/Geometry/HcalAlgo/plugins/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/DDLogicalPart.h"
00012 #include "DetectorDescription/Core/interface/DDCurrentNamespace.h"
00013 #include "Geometry/HcalAlgo/plugins/DDHCalTestBeamAlgo.h"
00014 #include "CLHEP/Units/GlobalSystemOfUnits.h"
00015 
00016 DDHCalTestBeamAlgo::DDHCalTestBeamAlgo() {
00017   LogDebug("HCalGeom") << "DDHCalTestBeamAlgo test: Creating an instance";
00018 }
00019 
00020 DDHCalTestBeamAlgo::~DDHCalTestBeamAlgo() {}
00021 
00022 void DDHCalTestBeamAlgo::initialize(const DDNumericArguments & nArgs,
00023                                     const DDVectorArguments & ,
00024                                     const DDMapArguments & ,
00025                                     const DDStringArguments & sArgs,
00026                                     const DDStringVectorArguments & ) {
00027 
00028   eta        = nArgs["Eta"];
00029   theta      = 2.0*atan(exp(-eta));
00030   phi        = nArgs["Phi"];
00031   distance   = nArgs["Dist"];
00032   distanceZ  = nArgs["DistZ"];
00033   dz         = nArgs["Dz"];
00034   copyNumber = int (nArgs["Number"]);
00035   dist       = (distance+distanceZ/sin(theta));
00036   LogDebug("HCalGeom") << "DDHCalTestBeamAlgo debug: Parameters for position"
00037                        << "ing--" << " Eta " << eta << "\tPhi " 
00038                        << phi/CLHEP::deg << "\tTheta " << theta/CLHEP::deg 
00039                        << "\tDistance " << distance << "/" << distanceZ << "/"
00040                        << dist <<"\tDz " << dz <<"\tcopyNumber " << copyNumber;
00041 
00042   idNameSpace = DDCurrentNamespace::ns();
00043   childName   = sArgs["ChildName"]; 
00044   DDName parentName = parent().name(); 
00045   LogDebug("HCalGeom") << "DDHCalTestBeamAlgo debug: Parent " << parentName
00046                        << "\tChild " << childName << " NameSpace "
00047                        << idNameSpace;
00048 }
00049 
00050 void DDHCalTestBeamAlgo::execute(DDCompactView& cpv) {
00051 
00052   double thetax = 90.*CLHEP::deg + theta;
00053   double sthx   = sin(thetax);
00054   if (abs(sthx)>1.e-12) sthx = 1./sthx;
00055   else                  sthx = 1.;
00056   double phix   = atan2(sthx*cos(theta)*sin(phi),sthx*cos(theta)*cos(phi));
00057   double thetay = 90.*CLHEP::deg;
00058   double phiy   = 90.*CLHEP::deg + phi;
00059   double thetaz = theta;
00060   double phiz   = phi;
00061   
00062   DDRotation rotation;
00063   string rotstr = childName;
00064   LogDebug("HCalGeom") << "DDHCalTestBeamAlgo test: Creating a new rotation "
00065                        << rotstr << "\t" << thetax/CLHEP::deg << "," 
00066                        << phix/CLHEP::deg << "," << thetay/CLHEP::deg << "," 
00067                        << phiy/CLHEP::deg << "," << thetaz/CLHEP::deg <<"," 
00068                        << phiz/CLHEP::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  cpv.position(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 }