00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015 #include "Geometry/DTGeometryBuilder/src/DTGeometryBuilderFromCondDB.h"
00016
00017
00018 #include <CondFormats/GeometryObjects/interface/RecoIdealGeometry.h>
00019 #include <Geometry/DTGeometry/interface/DTGeometry.h>
00020 #include <DataFormats/MuonDetId/interface/DTChamberId.h>
00021 #include <DataFormats/MuonDetId/interface/DTSuperLayerId.h>
00022 #include <DataFormats/MuonDetId/interface/DTLayerId.h>
00023 #include "DataFormats/GeometrySurface/interface/RectangularPlaneBounds.h"
00024 #include "CLHEP/Units/GlobalSystemOfUnits.h"
00025
00026
00027 #include <iostream>
00028 using namespace std;
00029
00030
00031
00032
00033 DTGeometryBuilderFromCondDB::DTGeometryBuilderFromCondDB() {
00034 }
00035
00036
00037 DTGeometryBuilderFromCondDB::~DTGeometryBuilderFromCondDB() {
00038 }
00039
00040
00041 void
00042 DTGeometryBuilderFromCondDB::build(boost::shared_ptr<DTGeometry> theGeometry,
00043 const RecoIdealGeometry& rig) {
00044
00045 const std::vector<DetId>& detids(rig.detIds());
00046
00047
00048 size_t idt = 0;
00049 DTChamber* chamber(0);
00050 DTSuperLayer* sl(0);
00051 while(idt < detids.size()) {
00052
00053 if (int(*(rig.shapeStart(idt)))==0){
00054
00055
00056 if (chamber) theGeometry->add(chamber);
00057
00058 DTChamberId chid(detids[idt]);
00059
00060 chamber = buildChamber(chid, rig, idt);
00061 }
00062 else if (int(*(rig.shapeStart(idt)))==1){
00063 DTSuperLayerId slid(detids[idt]);
00064
00065 sl = buildSuperLayer(chamber, slid, rig, idt);
00066 theGeometry->add(sl);
00067 }
00068 else if (int(*(rig.shapeStart(idt)))==2){
00069 DTLayerId lid(detids[idt]);
00070
00071 DTLayer* lay = buildLayer(sl, lid, rig, idt);
00072 theGeometry->add(lay);
00073 } else {
00074 cout << "What is this?" << endl;
00075 }
00076 ++idt;
00077 }
00078 if (chamber) theGeometry->add(chamber);
00079 }
00080
00081 DTChamber* DTGeometryBuilderFromCondDB::buildChamber(const DetId& id,
00082 const RecoIdealGeometry& rig,
00083 size_t idt ) const {
00084 DTChamberId detId(id);
00085
00086
00087 float width = (*(rig.shapeStart(idt) + 1))/cm;
00088 float length = (*(rig.shapeStart(idt) + 2))/cm;
00089 float thickness = (*(rig.shapeStart(idt) + 3))/cm;
00090
00092
00093
00094
00095 RectangularPlaneBounds bound(width, length, thickness);
00096
00097
00098 RCPPlane surf(plane(rig.tranStart(idt), rig.rotStart(idt), bound));
00099
00100 DTChamber* chamber = new DTChamber(detId, surf);
00101
00102 return chamber;
00103 }
00104
00105 DTSuperLayer*
00106 DTGeometryBuilderFromCondDB::buildSuperLayer(DTChamber* chamber,
00107 const DetId& id,
00108 const RecoIdealGeometry& rig,
00109 size_t idt) const {
00110
00111 DTSuperLayerId slId(id);
00112
00113 float width = (*(rig.shapeStart(idt) + 1))/cm;
00114 float length = (*(rig.shapeStart(idt) + 2))/cm;
00115 float thickness = (*(rig.shapeStart(idt) + 3))/cm;
00116
00117 RectangularPlaneBounds bound(width, length, thickness);
00118
00119
00120 RCPPlane surf(plane(rig.tranStart(idt), rig.rotStart(idt), bound));
00121
00122 DTSuperLayer* slayer = new DTSuperLayer(slId, surf, chamber);
00123
00124
00125 chamber->add(slayer);
00126 return slayer;
00127 }
00128
00129 DTLayer*
00130 DTGeometryBuilderFromCondDB::buildLayer(DTSuperLayer* sl,
00131 const DetId& id,
00132 const RecoIdealGeometry& rig,
00133 size_t idt) const {
00134
00135 DTLayerId layId(id);
00136
00137
00138 float width = (*(rig.shapeStart(idt) + 1))/cm;
00139 float length = (*(rig.shapeStart(idt) + 2))/cm;
00140 float thickness = (*(rig.shapeStart(idt) + 3))/cm;
00141
00142
00143 RectangularPlaneBounds bound(width, length, thickness);
00144
00145 RCPPlane surf(plane(rig.tranStart(idt), rig.rotStart(idt), bound));
00146
00147
00148 int firstWire=int(*(rig.shapeStart(idt) + 4 ));
00149 int WCounter=int(*(rig.shapeStart(idt) + 5 ));
00150 double sensibleLenght=(*(rig.shapeStart(idt) + 6 ))/cm;
00151 DTTopology topology(firstWire, WCounter, sensibleLenght);
00152
00153 DTLayerType layerType;
00154
00155 DTLayer* layer = new DTLayer(layId, surf, topology, layerType, sl);
00156
00157
00158 sl->add(layer);
00159 return layer;
00160 }
00161
00162 DTGeometryBuilderFromCondDB::RCPPlane
00163 DTGeometryBuilderFromCondDB::plane(const vector<double>::const_iterator tranStart,
00164 const vector<double>::const_iterator rotStart,
00165 const Bounds& bounds) const {
00166
00167 const Surface::PositionType posResult(*(tranStart), *(tranStart+1), *(tranStart+2));
00168
00169 Surface::RotationType rotResult( *(rotStart+0), *(rotStart+1), *(rotStart+2),
00170 *(rotStart+3), *(rotStart+4), *(rotStart+5),
00171 *(rotStart+6), *(rotStart+7), *(rotStart+8) );
00172
00173 return RCPPlane( new BoundPlane( posResult, rotResult, bounds));
00174 }