CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_6_1_2_SLHC2_patch1/src/Geometry/GEMGeometryBuilder/src/GEMGeometryBuilderFromCondDB.cc

Go to the documentation of this file.
00001 
00005 #include "Geometry/GEMGeometryBuilder/src/GEMGeometryBuilderFromCondDB.h"
00006 #include "Geometry/GEMGeometry/interface/GEMGeometry.h"
00007 #include "Geometry/GEMGeometry/interface/GEMEtaPartitionSpecs.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/GEMNumberingScheme.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 GEMGeometryBuilderFromCondDB::GEMGeometryBuilderFromCondDB(bool comp11) :
00028   theComp11Flag(comp11)
00029 { }
00030 
00031 GEMGeometryBuilderFromCondDB::~GEMGeometryBuilderFromCondDB() 
00032 { }
00033 
00034 GEMGeometry* GEMGeometryBuilderFromCondDB::build(const RecoIdealGeometry& rgeo)
00035 {
00036   const std::vector<DetId>& detids(rgeo.detIds());
00037   GEMGeometry* geometry = new GEMGeometry();
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     GEMDetId gemid(detids[id]);
00048     //    GEMDetId chid(gemid.region(),gemid.ring(),gemid.station(),
00049     //            gemid.sector(),gemid.layer(),gemid.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     Bounds* bounds = 0;
00064     float be = *(shapeStart+0)/cm;
00065     float te = *(shapeStart+1)/cm;
00066     float ap = *(shapeStart+2)/cm;
00067     float ti = *(shapeStart+3)/cm;
00068     float nstrip = *(shapeStart+4);
00069     float npad = *(shapeStart+5);
00070     //  TrapezoidalPlaneBounds* 
00071     bounds = new TrapezoidalPlaneBounds(be, te, ap, ti);
00072 
00073     std::vector<float> pars;
00074     pars.push_back(be); //b/2;
00075     pars.push_back(te); //B/2;
00076     pars.push_back(ap); //h/2;
00077     pars.push_back(nstrip);
00078     pars.push_back(npad);
00079     
00080     GEMEtaPartitionSpecs* e_p_specs = new GEMEtaPartitionSpecs(GeomDetEnumerators::GEM, name, pars);
00081       
00082       //Change of axes for the forward
00083     Basic3DVector<float> newX(1.,0.,0.);
00084     Basic3DVector<float> newY(0.,0.,1.);
00085     //      if (tran[2] > 0. )
00086     newY *= -1;
00087     Basic3DVector<float> newZ(0.,1.,0.);
00088     rot.rotateAxes (newX, newY, newZ);  
00089   
00090     
00091     BoundPlane* bp = new BoundPlane(pos, rot, bounds);
00092     ReferenceCountingPointer<BoundPlane> surf(bp);
00093     GEMEtaPartition* gep=new GEMEtaPartition(gemid, surf, e_p_specs);
00094     geometry->add(gep);
00095     
00096     
00097     std::list<GEMEtaPartition *> gepls;
00098     /*
00099     if (chids.find(chid)!=chids.end()){
00100       gepls = chids[chid];
00101     }
00102     */
00103     gepls.push_back(gep);
00104     //chids[chid]=gepls;
00105     
00106   }
00107   /*
00108   // Create the GEMChambers and store them on the Geometry 
00109 
00110   for( std::map<GEMDetId, std::list<GEMEtaPartition *> >::iterator ich=chids.begin();
00111        ich != chids.end(); ich++){
00112     GEMDetId chid = ich->first;
00113     std::list<GEMEtaPartition * > gepls = ich->second;
00114 
00115     // compute the overall boundplane. At the moment we use just the last
00116     // surface
00117     BoundPlane* bp=0;
00118     for(std::list<GEMEtaPartition *>::iterator gepl=gepls.begin();
00119     gepl!=gepls.end(); gepl++){
00120     const BoundPlane& bps = (*gepl)->surface();
00121       bp = const_cast<BoundPlane *>(&bps);
00122     }
00123 
00124     ReferenceCountingPointer<BoundPlane> surf(bp);
00125     // Create the chamber 
00126     GEMChamber* ch = new GEMChamber (chid, surf); 
00127     // Add the etaps to rhe chamber
00128     for(std::list<GEMEtaPartition *>::iterator gepl=gepls.begin();
00129     gepl!=gepls.end(); gepl++){
00130       ch->add(*gepl);
00131     }
00132     // Add the chamber to the geometry
00133     geometry->add(ch);
00134 
00135   }
00136   */
00137   return geometry;
00138 }
00139 
00140     
00141