CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_4_1_8_patch9/src/Geometry/RPCGeometryBuilder/src/RPCGeometryParsFromDD.cc

Go to the documentation of this file.
00001 
00006 #include "Geometry/RPCGeometryBuilder/src/RPCGeometryParsFromDD.h"
00007 #include "DataFormats/MuonDetId/interface/RPCDetId.h"
00008 
00009 #include <CondFormats/GeometryObjects/interface/RecoIdealGeometry.h>
00010 #include <DetectorDescription/Core/interface/DDFilter.h>
00011 #include <DetectorDescription/Core/interface/DDFilteredView.h>
00012 #include <DetectorDescription/Core/interface/DDSolid.h>
00013 
00014 #include "Geometry/MuonNumbering/interface/MuonDDDNumbering.h"
00015 #include "Geometry/MuonNumbering/interface/MuonBaseNumber.h"
00016 #include "Geometry/MuonNumbering/interface/RPCNumberingScheme.h"
00017 
00018 #include "DataFormats/GeometryVector/interface/Basic3DVector.h"
00019 
00020 #include "CLHEP/Units/GlobalSystemOfUnits.h"
00021 
00022 #include <iostream>
00023 #include <algorithm>
00024 
00025 RPCGeometryParsFromDD::RPCGeometryParsFromDD() 
00026 { }
00027 
00028 RPCGeometryParsFromDD::~RPCGeometryParsFromDD() 
00029 { }
00030 
00031 void
00032 RPCGeometryParsFromDD::build(const DDCompactView* cview, 
00033       const MuonDDDConstants& muonConstants, RecoIdealGeometry& rgeo )
00034 {
00035   std::string attribute = "ReadOutName"; // could come from .orcarc
00036   std::string value     = "MuonRPCHits";    // could come from .orcarc
00037   DDValue val(attribute, value, 0.0);
00038 
00039   // Asking only for the MuonRPC's
00040   DDSpecificsFilter filter;
00041   filter.setCriteria(val, // name & value of a variable 
00042                      DDSpecificsFilter::matches,
00043                      DDSpecificsFilter::AND, 
00044                      true, // compare strings otherwise doubles
00045                      true // use merged-specifics or simple-specifics
00046                      );
00047   DDFilteredView fview(*cview);
00048   fview.addFilter(filter);
00049 
00050   this->buildGeometry(fview, muonConstants, rgeo);
00051 }
00052 
00053 void
00054 RPCGeometryParsFromDD::buildGeometry(DDFilteredView& fview, const MuonDDDConstants& muonConstants, RecoIdealGeometry& rgeo)
00055 {
00056 
00057   bool doSubDets = fview.firstChild();
00058 
00059   while (doSubDets){
00060 
00061     // Get the Base Muon Number
00062     MuonDDDNumbering mdddnum(muonConstants);
00063     MuonBaseNumber   mbn=mdddnum.geoHistoryToBaseNumber(fview.geoHistory());
00064 
00065     // Get the The Rpc det Id 
00066     RPCNumberingScheme rpcnum(muonConstants);
00067     int detid = 0;
00068 
00069     detid = rpcnum.baseNumberToUnitNumber(mbn);
00070     RPCDetId rpcid(detid);
00071 
00072     DDValue numbOfStrips("nStrips");
00073 
00074     std::vector<const DDsvalues_type* > specs(fview.specifics());
00075     std::vector<const DDsvalues_type* >::iterator is=specs.begin();
00076     int nStrips=0;
00077     for (;is!=specs.end(); is++){
00078       if (DDfetch( *is, numbOfStrips)){
00079         nStrips=int(numbOfStrips.doubles()[0]); 
00080       }
00081     }
00082     if (nStrips == 0 )
00083       std::cout <<"No strip found!!"<<std::endl;
00084     
00085     std::vector<double> dpar=fview.logicalPart().solid().parameters();
00086 
00087     std::vector<std::string> strpars;
00088     std::string name=fview.logicalPart().name().name();
00089     strpars.push_back(name);
00090     DDTranslation tran    = fview.translation();
00091 
00092     DDRotationMatrix rota = fview.rotation();//.Inverse();
00093     DD3Vector x, y, z;
00094     rota.GetComponents(x,y,z);
00095     std::vector<double> pars;    
00096     if (dpar.size()==3){
00097       double width     = dpar[0];
00098       double length    = dpar[1];
00099       double thickness = dpar[2];
00100       pars.push_back(width);
00101       pars.push_back(length);
00102       pars.push_back(thickness);
00103       pars.push_back(numbOfStrips.doubles()[0]); 
00104     }else{
00105       pars.push_back(dpar[4]); //b/2;
00106       pars.push_back(dpar[8]); //B/2;
00107       pars.push_back(dpar[0]); //h/2;
00108       pars.push_back(0.4);
00109       pars.push_back(numbOfStrips.doubles()[0]); //h/2;
00110     }
00111 
00112     
00113     std::vector<double> vtra(3);
00114     std::vector<double> vrot(9);
00115     vtra[0]=(float) 1.0 * (tran.x());
00116     vtra[1]=(float) 1.0 * (tran.y());
00117     vtra[2]=(float) 1.0 * (tran.z());
00118     vrot[0]=(float) 1.0 * x.X();
00119     vrot[1]=(float) 1.0 * x.Y();
00120     vrot[2]=(float) 1.0 * x.Z();
00121     vrot[3]=(float) 1.0 * y.X();
00122     vrot[4]=(float) 1.0 * y.Y();
00123     vrot[5]=(float) 1.0 * y.Z();
00124     vrot[6]=(float) 1.0 * z.X();
00125     vrot[7]=(float) 1.0 * z.Y();
00126     vrot[8]=(float) 1.0 * z.Z();
00127     rgeo.insert(rpcid.rawId(),vtra,vrot, pars,strpars);
00128     doSubDets = fview.nextSibling(); // go to next layer
00129   }
00130   
00131 }