CMS 3D CMS Logo

/afs/cern.ch/work/a/aaltunda/public/www/CMSSW_6_2_5/src/SLHCUpgradeSimulations/Geometry/src/DDPixBarStackTrigLayerAlgo.cc

Go to the documentation of this file.
00001 
00002 // File: DDPixBarStackTrigLayerAlgo.cc
00003 // Description: Make one stack trig layer of pixel barrel detector
00005 
00006 #include <cmath>
00007 #include <algorithm>
00008 
00009 #include "FWCore/MessageLogger/interface/MessageLogger.h"
00010 #include "DetectorDescription/Base/interface/DDutils.h"
00011 #include "DetectorDescription/Core/interface/DDLogicalPart.h"
00012 #include "DetectorDescription/Core/interface/DDSolid.h"
00013 #include "DetectorDescription/Core/interface/DDMaterial.h"
00014 #include "DetectorDescription/Core/interface/DDCurrentNamespace.h"
00015 #include "DetectorDescription/Core/interface/DDSplit.h"
00016 #include "SLHCUpgradeSimulations/Geometry/interface/DDPixBarStackTrigLayerAlgo.h"
00017 #include "CLHEP/Units/PhysicalConstants.h"
00018 #include "CLHEP/Units/SystemOfUnits.h"
00019 
00020 
00021 DDPixBarStackTrigLayerAlgo::DDPixBarStackTrigLayerAlgo() {
00022   LogDebug("PixelGeom") <<"DDPixBarStackTrigLayerAlgo info: Creating an instance";
00023 }
00024 
00025 DDPixBarStackTrigLayerAlgo::~DDPixBarStackTrigLayerAlgo() {}
00026 
00027 void DDPixBarStackTrigLayerAlgo::initialize(const DDNumericArguments & nArgs,
00028                                    const DDVectorArguments & vArgs,
00029                                    const DDMapArguments & ,
00030                                    const DDStringArguments & sArgs,
00031                                    const DDStringVectorArguments & vsArgs) {
00032 
00033   idNameSpace = DDCurrentNamespace::ns();
00034 
00035   genMat    = sArgs["GeneralMaterial"];
00036   number    = int(nArgs["Ladders"]);
00037 
00038   layerDz   = nArgs["LayerDz"];
00039   layerR    = nArgs["LayerR"];
00040 
00041   ladder      = vsArgs["LadderName"];
00042   ladderWidth = vArgs["LadderWidth"];
00043   ladderThick = vArgs["LadderThick"];
00044   LogDebug("PixelGeom") << " in stacktrig algo: number = " << number
00045                         << " layerDz = " << layerDz
00046                         << " layerR  = " << layerR << std::endl;
00047 }
00048 
00049 void DDPixBarStackTrigLayerAlgo::execute(DDCompactView& cpv) {
00050 
00051   DDName      mother = parent().name();
00052   std::string idName = DDSplit(mother).first;
00053 
00054   double dphi = CLHEP::twopi/number;
00055 
00056   // Firstly Create Solid volumon for Stack Trig layer.
00057   double rtmi = cos(0.5*dphi)*layerR- ladderThick[0] ;  //fix  me here  for temporary test.
00058   double rtmx = layerR ;
00059   DDSolid solid = DDSolidFactory::tubs(DDName(idName, idNameSpace),0.5*layerDz,
00060                                        rtmi, rtmx, 0, CLHEP::twopi);
00061   LogDebug("PixelGeom") << "DDPixBarLayerAlgo test: "
00062                         << DDName(idName, idNameSpace) << " Tubs made of "
00063                         << genMat << " from 0 to " << CLHEP::twopi/CLHEP::deg
00064                         << " with Rin " << rtmi << " Rout " << rtmx
00065                         << " ZHalf " << 0.5*layerDz;
00066   // Create Logical  volume  for Stack Trig Layer
00067   DDName matname(DDSplit(genMat).first, DDSplit(genMat).second);
00068   DDMaterial matter(matname);
00069   DDLogicalPart layer(solid.ddname(), matter, solid);
00070   // Note, How to place this stack Trig layer will be defined in data/stacktriglayer0.xml
00071 
00072   DDName ladderFull(DDSplit(ladder[0]).first, DDSplit(ladder[0]).second);
00073 
00074   int  copy=1, iup=-1;
00075   double phi0 = 90*CLHEP::deg;
00076   for (int i=0; i<number; i++) {
00077         
00078     double phi = phi0 + i*dphi;
00079     double phix, phiy, rrr ;
00080     std::string rots;
00081     // Create Translation  for each Ladder.
00082     DDTranslation tran;
00083     DDRotation rot;
00084       iup  =-iup;
00085       rrr  = rtmi+ 0.5* ladderThick[0];
00086       tran = DDTranslation(rrr*cos(phi), rrr*sin(phi), 0);
00087       rots = idName + dbl_to_string(copy);
00088       if (iup > 0) phix = phi-90*CLHEP::deg;
00089       else         phix = phi+90*CLHEP::deg;
00090       phiy = phix+90.*CLHEP::deg;
00091 
00092       LogDebug("PixelGeom") << "DDPixBarStackTrigLayerAlgo test: Creating a new "
00093                             << "rotation: " << rots << "\t90., " << phix/CLHEP::deg 
00094                             << ", 90.," << phiy/CLHEP::deg << ", 0, 0"; 
00095       
00096       //Create Rotation for each Ladder.
00097       rot = DDrot(DDName(rots,idNameSpace), 90*CLHEP::deg, phix, 90*CLHEP::deg, phiy, 0.,0.);
00098 
00099      //Place each Ladder into this Stack  Trig Layer
00100       cpv.position (ladderFull, layer, copy, tran, rot);
00101 
00102       LogDebug("PixelGeom") << "DDPixBarStackTrigLayerAlgo test: " << ladderFull 
00103                             << " number " << copy << " positioned in " 
00104                             << layer.name() << " at " << tran << " with " 
00105                             << rot; 
00106       copy++;
00107 
00108   }
00109 }