CMS 3D CMS Logo

/data/doxygen/doxygen-1.7.3/gen/CMSSW_4_2_8/src/Geometry/DTGeometryBuilder/src/DTGeometryBuilderFromCondDB.cc

Go to the documentation of this file.
00001 /******* \class DTGeometryBuilderFromCondDB *******
00002  *
00003  * Description:
00004  *  
00005  *  detailed description
00006  *
00007  * \author : Stefano Lacaprara - INFN LNL <stefano.lacaprara@pd.infn.it>
00008  * $date   : 19/11/2008 19:15:14 CET $
00009  *
00010  * Modification:
00011  *
00012  *********************************/
00013 
00014 /* This Class Header */
00015 #include "Geometry/DTGeometryBuilder/src/DTGeometryBuilderFromCondDB.h"
00016 
00017 /* Collaborating Class Header */
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 /* C++ Headers */
00027 #include <iostream>
00028 using namespace std;
00029 
00030 /* ====================================================================== */
00031 
00032 /* Constructor */ 
00033 DTGeometryBuilderFromCondDB::DTGeometryBuilderFromCondDB() {
00034 }
00035 
00036 /* Destructor */ 
00037 DTGeometryBuilderFromCondDB::~DTGeometryBuilderFromCondDB() {
00038 }
00039 
00040 /* Operations */ 
00041 void
00042 DTGeometryBuilderFromCondDB::build(boost::shared_ptr<DTGeometry> theGeometry,
00043                                    const RecoIdealGeometry& rig) {
00044   //  cout << "DTGeometryBuilderFromCondDB " << endl;
00045   const std::vector<DetId>& detids(rig.detIds());
00046   //  cout << "size " << detids.size() << endl;
00047 
00048   size_t idt = 0;
00049   DTChamber* chamber(0);
00050   DTSuperLayer* sl(0);
00051   while(idt < detids.size()) {
00052     //copy(par.begin(), par.end(), ostream_iterator<double>(std::cout," "));
00053     if (int(*(rig.shapeStart(idt)))==0){ // a Chamber
00054       // add the provious chamber which by now has been updated with SL and
00055       // layers
00056       if (chamber) theGeometry->add(chamber);
00057       // go for the actual one
00058       DTChamberId chid(detids[idt]);
00059       //cout << "CH: " <<  chid << endl;
00060       chamber = buildChamber(chid, rig, idt); 
00061     }
00062     else if (int(*(rig.shapeStart(idt)))==1){ // a SL
00063       DTSuperLayerId slid(detids[idt]);
00064       //cout << "  SL: " <<  slid << endl;
00065       sl = buildSuperLayer(chamber, slid, rig, idt);
00066       theGeometry->add(sl);
00067     }
00068     else if (int(*(rig.shapeStart(idt)))==2){ // a Layer
00069       DTLayerId lid(detids[idt]);
00070       //cout << "    LAY: " <<  lid << endl;
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); // add the last 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;     // r-phi  dimension - different in different chambers
00088   float length = (*(rig.shapeStart(idt) + 2))/cm;    // z      dimension - constant 125.55 cm
00089   float thickness = (*(rig.shapeStart(idt) + 3))/cm; // radial thickness - almost constant about 18 cm
00090 
00092   // width is along local X
00093   // length is along local Y
00094   // thickness is long local Z
00095   RectangularPlaneBounds bound(width, length, thickness);
00096   //  std::vector<double> tran(rig.tranStart(idt), rig.tranEnd(idt));
00097   //  std::vector<double> rot(rig.rotStart(idt), rig.rotEnd(idt));
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;     // r-phi  dimension - different in different chambers
00114   float length = (*(rig.shapeStart(idt) + 2))/cm;    // z      dimension - constant 126.8 cm
00115   float thickness = (*(rig.shapeStart(idt) + 3))/cm; // radial thickness - almost constant about 5 cm
00116 
00117   RectangularPlaneBounds bound(width, length, thickness);
00118 
00119   // Ok this is the slayer position...
00120   RCPPlane surf(plane(rig.tranStart(idt), rig.rotStart(idt), bound));
00121 
00122   DTSuperLayer* slayer = new DTSuperLayer(slId, surf, chamber);
00123 
00124   // cout << "adding slayer " << slayer->id() << " to chamber "<<  chamber->id() << endl;
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   // Layer specific parameter (size)
00138   float width = (*(rig.shapeStart(idt) + 1))/cm;     // r-phi  dimension - changes in different chambers
00139   float length = (*(rig.shapeStart(idt) + 2))/cm;    // z      dimension - constant 126.8 cm
00140   float thickness = (*(rig.shapeStart(idt) + 3))/cm; // radial thickness - almost constant about 20 cm
00141 
00142   // define Bounds
00143   RectangularPlaneBounds bound(width, length, thickness);
00144 
00145   RCPPlane surf(plane(rig.tranStart(idt), rig.rotStart(idt), bound));//tran, rot, bound));
00146 
00147   // Loop on wires
00148   int firstWire=int(*(rig.shapeStart(idt) + 4 ));//par[4]);
00149   int WCounter=int(*(rig.shapeStart(idt) + 5 ));//par[5]);
00150   double sensibleLenght=(*(rig.shapeStart(idt) + 6 ))/cm;//par[6]/cm;
00151   DTTopology topology(firstWire, WCounter, sensibleLenght);
00152 
00153   DTLayerType layerType;
00154 
00155   DTLayer* layer = new DTLayer(layId, surf, topology, layerType, sl);
00156   // cout << "adding layer " << layer->id() << " to sl "<<  sl->id() << endl;
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   // extract the position
00167   const Surface::PositionType posResult(*(tranStart), *(tranStart+1), *(tranStart+2));
00168   // now the rotation
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 }