CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_3_3/src/Geometry/RPCGeometryBuilder/src/RPCGeometryBuilderFromCondDB.cc

Go to the documentation of this file.
00001 
00005 #include "Geometry/RPCGeometryBuilder/src/RPCGeometryBuilderFromCondDB.h"
00006 #include "Geometry/RPCGeometry/interface/RPCGeometry.h"
00007 #include "Geometry/RPCGeometry/interface/RPCRollSpecs.h"
00008 
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/RPCNumberingScheme.h"
00016 
00017 #include "DataFormats/GeometrySurface/interface/RectangularPlaneBounds.h"
00018 #include "DataFormats/GeometrySurface/interface/TrapezoidalPlaneBounds.h"
00019 
00020 #include "DataFormats/GeometryVector/interface/Basic3DVector.h"
00021 
00022 #include "CLHEP/Units/GlobalSystemOfUnits.h"
00023 
00024 #include <iostream>
00025 #include <algorithm>
00026 
00027 RPCGeometryBuilderFromCondDB::RPCGeometryBuilderFromCondDB(bool comp11) :
00028   theComp11Flag(comp11)
00029 { }
00030 
00031 RPCGeometryBuilderFromCondDB::~RPCGeometryBuilderFromCondDB() 
00032 { }
00033 
00034 RPCGeometry* RPCGeometryBuilderFromCondDB::build(const RecoIdealGeometry& rgeo)
00035 {
00036   const std::vector<DetId>& detids(rgeo.detIds());
00037   RPCGeometry* geometry = new RPCGeometry();
00038   
00039   std::string name;
00040   std::vector<double>::const_iterator tranStart;
00041   std::vector<double>::const_iterator shapeStart;
00042   std::vector<double>::const_iterator rotStart;
00043   std::vector<std::string>::const_iterator strStart;
00044   
00045   for (unsigned int id=0; id<detids.size(); id++){
00046     
00047     RPCDetId rpcid(detids[id]);
00048     RPCDetId chid(rpcid.region(),rpcid.ring(),rpcid.station(),
00049                   rpcid.sector(),rpcid.layer(),rpcid.subsector(),0);
00050     
00051     tranStart=rgeo.tranStart(id);
00052     shapeStart=rgeo.shapeStart(id);
00053     rotStart=rgeo.rotStart(id);
00054     strStart=rgeo.strStart(id);
00055     name=*(strStart);
00056 
00057     Surface::PositionType pos(*(tranStart)/cm,*(tranStart+1)/cm, *(tranStart+2)/cm);
00058     // CLHEP way
00059     Surface::RotationType rot(*(rotStart+0),*(rotStart+1),*(rotStart+2),
00060                               *(rotStart+3),*(rotStart+4),*(rotStart+5),
00061                               *(rotStart+6),*(rotStart+7),*(rotStart+8));
00062       
00063     std::vector<float> pars;
00064     RPCRollSpecs* rollspecs= 0;
00065     Bounds* bounds = 0;
00066     
00067     //    if (dpar.size()==4){
00068     if ( rgeo.shapeEnd(id) - shapeStart == 4 ) {
00069       float width     = *(shapeStart+0)/cm;
00070       float length    = *(shapeStart+1)/cm;
00071       float thickness = *(shapeStart+2)/cm;
00072       float nstrip    = *(shapeStart+3);
00073       //RectangularPlaneBounds* 
00074       bounds = 
00075         new RectangularPlaneBounds(width,length,thickness);
00076       pars.push_back(width);
00077       pars.push_back(length);
00078       pars.push_back(nstrip); 
00079 
00080       if (!theComp11Flag) {
00081         //Correction of the orientation to get the REAL geometry.
00082         //Change of axes for the +z part only.
00083         //Including the 0 whell
00084         if ( *(tranStart+2) > -1500.) {   //tran[2] >-1500. ){
00085           Basic3DVector<float> newX(-1.,0.,0.);
00086           Basic3DVector<float> newY(0.,-1.,0.);
00087           Basic3DVector<float> newZ(0.,0.,1.);
00088           rot.rotateAxes (newX, newY,newZ);
00089         }
00090       }
00091 
00092       
00093       rollspecs = new RPCRollSpecs(GeomDetEnumerators::RPCBarrel,name,pars);
00094       
00095       
00096     }else{
00097       float be = *(shapeStart+0)/cm;
00098       float te = *(shapeStart+1)/cm;
00099       float ap = *(shapeStart+2)/cm;
00100       float ti = *(shapeStart+3)/cm;
00101       float nstrip = *(shapeStart+4);
00102       //  TrapezoidalPlaneBounds* 
00103       bounds = 
00104         new TrapezoidalPlaneBounds(be,te,ap,ti);
00105       pars.push_back(be); //b/2;
00106       pars.push_back(te); //B/2;
00107       pars.push_back(ap); //h/2;
00108       pars.push_back(nstrip); 
00109       
00110       rollspecs = new RPCRollSpecs(GeomDetEnumerators::RPCEndcap,name,pars);
00111       
00112       //Change of axes for the forward
00113       Basic3DVector<float> newX(1.,0.,0.);
00114       Basic3DVector<float> newY(0.,0.,1.);
00115       //      if (tran[2] > 0. )
00116       newY *= -1;
00117       Basic3DVector<float> newZ(0.,1.,0.);
00118       rot.rotateAxes (newX, newY,newZ); 
00119     }
00120     
00121     BoundPlane* bp = new BoundPlane(pos,rot,bounds);
00122     ReferenceCountingPointer<BoundPlane> surf(bp);
00123     RPCRoll* r=new RPCRoll(rpcid,surf,rollspecs);
00124     geometry->add(r);
00125     
00126     std::list<RPCRoll *> rls;
00127     if (chids.find(chid)!=chids.end()){
00128       rls = chids[chid];
00129     }
00130     rls.push_back(r);
00131     chids[chid]=rls;
00132   }
00133   // Create the RPCChambers and store them on the Geometry 
00134   for( std::map<RPCDetId, std::list<RPCRoll *> >::iterator ich=chids.begin();
00135        ich != chids.end(); ich++){
00136     RPCDetId chid = ich->first;
00137     std::list<RPCRoll * > rls = ich->second;
00138 
00139     // compute the overall boundplane. At the moment we use just the last
00140     // surface
00141     BoundPlane* bp=0;
00142     for(std::list<RPCRoll *>::iterator rl=rls.begin();
00143     rl!=rls.end(); rl++){
00144       const BoundPlane& bps = (*rl)->surface();
00145       bp = const_cast<BoundPlane *>(&bps);
00146     }
00147 
00148     ReferenceCountingPointer<BoundPlane> surf(bp);
00149     // Create the chamber 
00150     RPCChamber* ch = new RPCChamber (chid, surf); 
00151     // Add the rolls to rhe chamber
00152     for(std::list<RPCRoll *>::iterator rl=rls.begin();
00153     rl!=rls.end(); rl++){
00154       ch->add(*rl);
00155     }
00156     // Add the chamber to the geometry
00157     geometry->add(ch);
00158 
00159   }
00160   return geometry;
00161 }
00162 
00163     
00164