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 {
00067 LogDebug("GEMGeometryBuilderFromDDD") <<"start the loop";
00068
00069
00070 MuonDDDNumbering mdddnum(muonConstants);
00071 LogDebug("GEMGeometryBuilderFromDDD") <<"Getting the Muon base Number";
00072 MuonBaseNumber mbn = mdddnum.geoHistoryToBaseNumber(fview.geoHistory());
00073 LogDebug("GEMGeometryBuilderFromDDD") <<"Start the GEM Numbering Schema";
00074
00075 GEMNumberingScheme gemnum(muonConstants);
00076 int detid = 0;
00077
00078 LogDebug("GEMGeometryBuilderFromDDD") <<"Getting the Unit Number";
00079 detid = gemnum.baseNumberToUnitNumber(mbn);
00080 LogDebug("GEMGeometryBuilderFromDDD") <<"Getting the GEM det Id "<<detid;
00081
00082 GEMDetId gemmid(detid);
00083
00084
00085 LogDebug("GEMGeometryBuilderFromDDD") <<"The GEMDetid is "<<gemmid;
00086
00087 DDValue numbOfStrips("nStrips");
00088 DDValue numbOfPads("nPads");
00089
00090 std::vector<const DDsvalues_type* > specs(fview.specifics());
00091 std::vector<const DDsvalues_type* >::iterator is = specs.begin();
00092 double nStrips = 0., nPads = 0.;
00093 for (;is != specs.end(); is++)
00094 {
00095 if (DDfetch( *is, numbOfStrips)) nStrips = numbOfStrips.doubles()[0];
00096 if (DDfetch( *is, numbOfPads)) nPads = numbOfPads.doubles()[0];
00097 }
00098 LogDebug("GEMGeometryBuilderFromDDD") << ((nStrips == 0. ) ? ("No nStrips found!!") : (""));
00099 LogDebug("GEMGeometryBuilderFromDDD") << ((nPads == 0. ) ? ("No nPads found!!") : (""));
00100
00101
00102
00103 std::vector<double> dpar=fview.logicalPart().solid().parameters();
00104 std::string name = fview.logicalPart().name().name();
00105 DDTranslation tran = fview.translation();
00106
00107 DDRotationMatrix rota = fview.rotation();
00108 Surface::PositionType pos(tran.x()/cm, tran.y()/cm, tran.z()/cm);
00109
00110
00111
00112
00113
00114
00115 DD3Vector x, y, z;
00116 rota.GetComponents(x,y,z);
00117
00118 Surface::RotationType rot (float(x.X()), float(x.Y()), float(x.Z()),
00119 float(y.X()), float(y.Y()), float(y.Z()),
00120 float(z.X()), float(z.Y()), float(z.Z()));
00121
00122 Bounds* bounds = 0;
00123 float be = dpar[4]/cm;
00124 float te = dpar[8]/cm;
00125 float ap = dpar[0]/cm;
00126 float ti = 0.4/cm;
00127
00128 bounds = new TrapezoidalPlaneBounds(be, te, ap, ti);
00129
00130 std::vector<float> pars;
00131 pars.push_back(dpar[4]/cm);
00132 pars.push_back(dpar[8]/cm);
00133 pars.push_back(dpar[0]/cm);
00134 pars.push_back(nStrips);
00135 pars.push_back(nPads);
00136
00137 LogDebug("GEMGeometryBuilderFromDDD") <<"GEM "<<name
00138 <<" par "<<dpar[4]/cm
00139 <<" "<<dpar[8]/cm<<" "<<dpar[3]/cm<<" "
00140 <<dpar[0];
00141
00142 GEMEtaPartitionSpecs* e_p_specs = new GEMEtaPartitionSpecs(GeomDetEnumerators::GEM, name, pars);
00143
00144
00145 Basic3DVector<float> newX(1.,0.,0.);
00146 Basic3DVector<float> newY(0.,0.,1.);
00147
00148 newY *= -1;
00149 Basic3DVector<float> newZ(0.,1.,0.);
00150 rot.rotateAxes (newX, newY, newZ);
00151
00152 LogDebug("GEMGeometryBuilderFromDDD") <<" Number of strips "<<nStrips<<" Number of pads "<<nPads;
00153 BoundPlane* bp = new BoundPlane(pos, rot, bounds);
00154 ReferenceCountingPointer<BoundPlane> surf(bp);
00155 GEMEtaPartition* gep = new GEMEtaPartition(gemmid, surf, e_p_specs);
00156 geometry->add(gep);
00157
00158 std::list<GEMEtaPartition *> gepls;
00159
00160
00161
00162
00163
00164 gepls.push_back(gep);
00165
00166
00167 doSubDets = fview.nextSibling();
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
00194
00195
00196
00197 return geometry;
00198 }