Go to the documentation of this file.00001
00005 #include "Geometry/GEMGeometryBuilder/src/GEMGeometryParsFromDD.h"
00006 #include "DataFormats/MuonDetId/interface/GEMDetId.h"
00007
00008 #include <CondFormats/GeometryObjects/interface/RecoIdealGeometry.h>
00009 #include <DetectorDescription/Core/interface/DDFilter.h>
00010 #include <DetectorDescription/Core/interface/DDFilteredView.h>
00011 #include <DetectorDescription/Core/interface/DDSolid.h>
00012
00013 #include "Geometry/MuonNumbering/interface/MuonDDDNumbering.h"
00014 #include "Geometry/MuonNumbering/interface/MuonBaseNumber.h"
00015 #include "Geometry/MuonNumbering/interface/GEMNumberingScheme.h"
00016
00017 #include "DataFormats/GeometryVector/interface/Basic3DVector.h"
00018
00019 #include "CLHEP/Units/GlobalSystemOfUnits.h"
00020
00021 #include <iostream>
00022 #include <algorithm>
00023
00024 GEMGeometryParsFromDD::GEMGeometryParsFromDD()
00025 { }
00026
00027 GEMGeometryParsFromDD::~GEMGeometryParsFromDD()
00028 { }
00029
00030 void
00031 GEMGeometryParsFromDD::build(const DDCompactView* cview,
00032 const MuonDDDConstants& muonConstants, RecoIdealGeometry& rgeo )
00033 {
00034 std::string attribute = "ReadOutName";
00035 std::string value = "MuonGEMHits";
00036 DDValue val(attribute, value, 0.0);
00037
00038
00039 DDSpecificsFilter filter;
00040 filter.setCriteria(val,
00041 DDSpecificsFilter::matches,
00042 DDSpecificsFilter::AND,
00043 true,
00044 true
00045 );
00046 DDFilteredView fview(*cview);
00047 fview.addFilter(filter);
00048
00049 this->buildGeometry(fview, muonConstants, rgeo);
00050 }
00051
00052 void
00053 GEMGeometryParsFromDD::buildGeometry(DDFilteredView& fview, const MuonDDDConstants& muonConstants, RecoIdealGeometry& rgeo)
00054 {
00055
00056 bool doSubDets = fview.firstChild();
00057
00058 while (doSubDets){
00059
00060
00061 MuonDDDNumbering mdddnum(muonConstants);
00062 MuonBaseNumber mbn = mdddnum.geoHistoryToBaseNumber(fview.geoHistory());
00063
00064
00065 GEMNumberingScheme gemnum(muonConstants);
00066 int detid = 0;
00067
00068 detid = gemnum.baseNumberToUnitNumber(mbn);
00069 GEMDetId gemid(detid);
00070
00071 DDValue numbOfStrips("nStrips");
00072 DDValue numbOfPads("nPads");
00073
00074 std::vector<const DDsvalues_type* > specs(fview.specifics());
00075 std::vector<const DDsvalues_type* >::iterator is = specs.begin();
00076 double nStrips = 0., nPads = 0.;
00077 for (;is!=specs.end(); is++)
00078 {
00079 if (DDfetch( *is, numbOfStrips)) nStrips = numbOfStrips.doubles()[0];
00080 if (DDfetch( *is, numbOfPads)) nPads = numbOfPads.doubles()[0];
00081 }
00082 LogDebug("GEMGeometryBuilderFromDDD") << ((nStrips == 0. ) ? ("No nStrips found!!") : (""));
00083 LogDebug("GEMGeometryBuilderFromDDD") << ((nPads == 0. ) ? ("No nPads found!!") : (""));
00084
00085
00086 std::vector<double> dpar = fview.logicalPart().solid().parameters();
00087
00088 std::vector<std::string> strpars;
00089 std::string name = fview.logicalPart().name().name();
00090 strpars.push_back(name);
00091 DDTranslation tran = fview.translation();
00092
00093 DDRotationMatrix rota = fview.rotation();
00094 DD3Vector x, y, z;
00095 rota.GetComponents(x,y,z);
00096 std::vector<double> pars;
00097 pars.push_back(dpar[4]);
00098 pars.push_back(dpar[8]);
00099 pars.push_back(dpar[0]);
00100 pars.push_back(0.4);
00101 pars.push_back(nStrips);
00102 pars.push_back(nPads);
00103
00104 std::vector<double> vtra(3);
00105 std::vector<double> vrot(9);
00106 vtra[0]=(float) 1.0 * (tran.x());
00107 vtra[1]=(float) 1.0 * (tran.y());
00108 vtra[2]=(float) 1.0 * (tran.z());
00109 vrot[0]=(float) 1.0 * x.X();
00110 vrot[1]=(float) 1.0 * x.Y();
00111 vrot[2]=(float) 1.0 * x.Z();
00112 vrot[3]=(float) 1.0 * y.X();
00113 vrot[4]=(float) 1.0 * y.Y();
00114 vrot[5]=(float) 1.0 * y.Z();
00115 vrot[6]=(float) 1.0 * z.X();
00116 vrot[7]=(float) 1.0 * z.Y();
00117 vrot[8]=(float) 1.0 * z.Z();
00118 rgeo.insert(gemid.rawId(), vtra, vrot, pars, strpars);
00119 doSubDets = fview.nextSibling();
00120 }
00121
00122 }