CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_6_1_2_SLHC2_patch1/src/Geometry/GEMGeometryBuilder/src/GEMGeometryParsFromDD.cc

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"; // could come from .orcarc
00035   std::string value     = "MuonGEMHits";    // could come from .orcarc
00036   DDValue val(attribute, value, 0.0);
00037 
00038   // Asking only for the MuonGEM's
00039   DDSpecificsFilter filter;
00040   filter.setCriteria(val, // name & value of a variable 
00041                      DDSpecificsFilter::matches,
00042                      DDSpecificsFilter::AND, 
00043                      true, // compare strings otherwise doubles
00044                      true // use merged-specifics or simple-specifics
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     // Get the Base Muon Number
00061     MuonDDDNumbering mdddnum(muonConstants);
00062     MuonBaseNumber   mbn = mdddnum.geoHistoryToBaseNumber(fview.geoHistory());
00063 
00064     // Get the The GEM det Id 
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     //std::cout <<"# strips, pads: "<< nStrips<<", "<<nPads<<std::endl;
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();//.Inverse();
00094     DD3Vector x, y, z;
00095     rota.GetComponents(x,y,z);
00096     std::vector<double> pars;    
00097     pars.push_back(dpar[4]); //b/2;
00098     pars.push_back(dpar[8]); //B/2;
00099     pars.push_back(dpar[0]); //h/2;
00100     pars.push_back(0.4); // XXX: what is that? hardcoded thickness?
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(); // go to next layer
00120   }
00121   
00122 }