Go to the documentation of this file.00001
00006 #include "Geometry/GEMGeometryBuilder/src/GEMGeometryBuilderFromDDD.h"
00007 #include "Geometry/GEMGeometry/interface/GEMGeometry.h"
00008 #include "Geometry/GEMGeometry/interface/GEMEtaPartitionSpecs.h"
00009
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/GEMNumberingScheme.h"
00017
00018 #include "DataFormats/GeometrySurface/interface/RectangularPlaneBounds.h"
00019 #include "DataFormats/GeometrySurface/interface/TrapezoidalPlaneBounds.h"
00020
00021 #include "DataFormats/GeometryVector/interface/Basic3DVector.h"
00022
00023 #include "CLHEP/Units/GlobalSystemOfUnits.h"
00024
00025 #include <iostream>
00026 #include <algorithm>
00027
00028 GEMGeometryBuilderFromDDD::GEMGeometryBuilderFromDDD(bool comp11) : theComp11Flag(comp11)
00029 { }
00030
00031 GEMGeometryBuilderFromDDD::~GEMGeometryBuilderFromDDD()
00032 { }
00033
00034 GEMGeometry* GEMGeometryBuilderFromDDD::build(const DDCompactView* cview, const MuonDDDConstants& muonConstants)
00035 {
00036 std::string attribute = "ReadOutName";
00037 std::string value = "MuonGEMHits";
00038 DDValue val(attribute, value, 0.0);
00039
00040
00041 DDSpecificsFilter filter;
00042 filter.setCriteria(val,
00043 DDSpecificsFilter::matches,
00044 DDSpecificsFilter::AND,
00045 true,
00046 true
00047 );
00048 DDFilteredView fview(*cview);
00049 fview.addFilter(filter);
00050
00051 return this->buildGeometry(fview, muonConstants);
00052 }
00053
00054 GEMGeometry* GEMGeometryBuilderFromDDD::buildGeometry(DDFilteredView& fview, const MuonDDDConstants& muonConstants)
00055 {
00056 LogDebug("GEMGeometryBuilderFromDDD") <<"Building the geometry service";
00057 GEMGeometry* geometry = new GEMGeometry();
00058
00059 LogDebug("GEMGeometryBuilderFromDDD") << "About to run through the GEM structure\n"
00060 <<" First logical part "
00061 <<fview.logicalPart().name().name();
00062 bool doSubDets = fview.firstChild();
00063
00064 LogDebug("GEMGeometryBuilderFromDDD") << "doSubDets = " << doSubDets;
00065 while (doSubDets){
00066 LogDebug("GEMGeometryBuilderFromDDD") <<"start the loop";
00067
00068
00069 MuonDDDNumbering mdddnum(muonConstants);
00070 LogDebug("GEMGeometryBuilderFromDDD") <<"Getting the Muon base Number";
00071 MuonBaseNumber mbn=mdddnum.geoHistoryToBaseNumber(fview.geoHistory());
00072 LogDebug("GEMGeometryBuilderFromDDD") <<"Start the GEM Numbering Schema";
00073
00074 GEMNumberingScheme gemnum(muonConstants);
00075 int detid = 0;
00076
00077 LogDebug("GEMGeometryBuilderFromDDD") <<"Getting the Unit Number";
00078 detid = gemnum.baseNumberToUnitNumber(mbn);
00079 LogDebug("GEMGeometryBuilderFromDDD") <<"Getting the GEM det Id "<<detid;
00080
00081 GEMDetId gemmid(detid);
00082
00083
00084 LogDebug("GEMGeometryBuilderFromDDD") <<"The GEMDetid is "<<gemmid;
00085
00086 DDValue numbOfStrips("nStrips");
00087
00088 std::vector<const DDsvalues_type* > specs(fview.specifics());
00089 std::vector<const DDsvalues_type* >::iterator is=specs.begin();
00090 int nStrips=0;
00091 for (;is!=specs.end(); is++){
00092 if (DDfetch( *is, numbOfStrips)){
00093 nStrips=int(numbOfStrips.doubles()[0]);
00094 }
00095 }
00096
00097 LogDebug("GEMGeometryBuilderFromDDD") << ((nStrips == 0 ) ? ("No strip found!!") : (""));
00098
00099 std::vector<double> dpar=fview.logicalPart().solid().parameters();
00100 std::string name=fview.logicalPart().name().name();
00101 DDTranslation tran = fview.translation();
00102
00103 DDRotationMatrix rota = fview.rotation();
00104 Surface::PositionType pos(tran.x()/cm,tran.y()/cm, tran.z()/cm);
00105
00106
00107
00108
00109
00110
00111 DD3Vector x, y, z;
00112 rota.GetComponents(x,y,z);
00113
00114 Surface::RotationType rot (float(x.X()),float(x.Y()),float(x.Z()),
00115 float(y.X()),float(y.Y()),float(y.Z()),
00116 float(z.X()),float(z.Y()),float(z.Z()));
00117
00118 std::vector<float> pars;
00119 GEMEtaPartitionSpecs* etapartitionspecs= 0;
00120 Bounds* bounds = 0;
00121
00122 float be = dpar[4]/cm;
00123 float te = dpar[8]/cm;
00124 float ap = dpar[0]/cm;
00125 float ti = 0.4/cm;
00126
00127 bounds =
00128 new TrapezoidalPlaneBounds(be,te,ap,ti);
00129 pars.push_back(dpar[4]/cm);
00130 pars.push_back(dpar[8]/cm);
00131 pars.push_back(dpar[0]/cm);
00132 pars.push_back(numbOfStrips.doubles()[0]);
00133 LogDebug("GEMGeometryBuilderFromDDD") <<"GEM "<<name
00134 <<" par "<<dpar[4]/cm
00135 <<" "<<dpar[8]/cm<<" "<<dpar[3]/cm<<" "
00136 <<dpar[0];
00137
00138 etapartitionspecs = new GEMEtaPartitionSpecs(GeomDetEnumerators::GEM,name,pars);
00139
00140
00141 Basic3DVector<float> newX(1.,0.,0.);
00142 Basic3DVector<float> newY(0.,0.,1.);
00143
00144 newY *= -1;
00145 Basic3DVector<float> newZ(0.,1.,0.);
00146 rot.rotateAxes (newX, newY,newZ);
00147
00148 LogDebug("GEMGeometryBuilderFromDDD") <<" Number of strips "<<nStrips;
00149 BoundPlane* bp = new BoundPlane(pos,rot,bounds);
00150 ReferenceCountingPointer<BoundPlane> surf(bp);
00151 GEMEtaPartition* gep=new GEMEtaPartition(gemmid,surf,etapartitionspecs);
00152 geometry->add(gep);
00153
00154 std::list<GEMEtaPartition *> gepls;
00155
00156
00157
00158
00159
00160 gepls.push_back(gep);
00161
00162
00163 doSubDets = fview.nextSibling();
00164 }
00165
00166
00167
00168
00169
00170
00171
00172
00173
00174
00175
00176
00177
00178
00179
00180
00181
00182
00183
00184
00185
00186
00187
00188
00189
00190
00191
00192
00193 return geometry;
00194 }