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";
00036 std::string value = "MuonRPCHits";
00037 DDValue val(attribute, value, 0.0);
00038
00039
00040 DDSpecificsFilter filter;
00041 filter.setCriteria(val,
00042 DDSpecificsFilter::matches,
00043 DDSpecificsFilter::AND,
00044 true,
00045 true
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
00062 MuonDDDNumbering mdddnum(muonConstants);
00063 MuonBaseNumber mbn=mdddnum.geoHistoryToBaseNumber(fview.geoHistory());
00064
00065
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();
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]);
00106 pars.push_back(dpar[8]);
00107 pars.push_back(dpar[0]);
00108 pars.push_back(0.4);
00109 pars.push_back(numbOfStrips.doubles()[0]);
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();
00129 }
00130
00131 }