CMS 3D CMS Logo

TrackerGeomBuilderFromGeometricDet.cc

Go to the documentation of this file.
00001 
00002 
00003 //#include "DetectorDescription/Core/interface/DDExpandedView.h"
00004 //temporary
00005 //#include "DetectorDescription/Core/interface/DDSolid.h"
00006 //
00007 #include "Geometry/TrackerGeometryBuilder/interface/TrackerGeomBuilderFromGeometricDet.h"
00008 #include "Geometry/TrackerGeometryBuilder/interface/TrackerGeometry.h"
00009 #include "Geometry/TrackerGeometryBuilder/interface/PlaneBuilderForGluedDet.h"
00010 #include "Geometry/CommonDetUnit/interface/GeomDetUnit.h"
00011 #include "Geometry/TrackerGeometryBuilder/interface/GluedGeomDet.h"
00012 #include "Geometry/CommonDetUnit/interface/GeomDetType.h"
00013 #include "Geometry/TrackerGeometryBuilder/interface/PixelGeomDetType.h"
00014 #include "Geometry/TrackerGeometryBuilder/interface/PixelGeomDetUnit.h"
00015 #include "Geometry/TrackerGeometryBuilder/interface/StripGeomDetType.h"
00016 #include "Geometry/TrackerGeometryBuilder/interface/StripGeomDetUnit.h"
00017 #include "DataFormats/DetId/interface/DetId.h"
00018 #include "DataFormats/SiStripDetId/interface/StripSubdetector.h"
00019 #include "DataFormats/GeometrySurface/interface/MediumProperties.h"
00020 
00021 
00022 #include <cfloat>
00023 
00024 using std::vector;
00025 using std::string;
00026 
00027 
00028 TrackerGeometry* TrackerGeomBuilderFromGeometricDet::build( const GeometricDet* gd){
00029 
00030   TrackerGeometry* tracker = new TrackerGeometry(gd);
00031   std::vector<const GeometricDet*> comp;
00032   gd->deepComponents(comp);
00033 
00034   std::vector<const GeometricDet*> dets[6];
00035   std::vector<const GeometricDet*> & pixB = dets[0]; pixB.reserve(comp.size());
00036   std::vector<const GeometricDet*> & pixF = dets[1]; pixF.reserve(comp.size());
00037   std::vector<const GeometricDet*> & tib  = dets[2];  tib.reserve(comp.size());
00038   std::vector<const GeometricDet*> & tid  = dets[3];  tid.reserve(comp.size());
00039   std::vector<const GeometricDet*> & tob  = dets[4];  tob.reserve(comp.size());
00040   std::vector<const GeometricDet*> & tec  = dets[5];  tec.reserve(comp.size());
00041 
00042   for(u_int32_t i = 0;i<comp.size();i++)
00043     dets[comp[i]->geographicalID().subdetId()-1].push_back(comp[i]);
00044   
00045 
00046   buildPixel(pixB,tracker,theDetIdToEnum.type(1), "barrel"); //"PixelBarrel" 
00047   buildPixel(pixF,tracker,theDetIdToEnum.type(2), "endcap"); //"PixelEndcap" 
00048   buildSilicon(tib,tracker,theDetIdToEnum.type(3), "barrel");// "TIB"   
00049   buildSilicon(tid,tracker,theDetIdToEnum.type(4), "endcap");//"TID" 
00050   buildSilicon(tob,tracker,theDetIdToEnum.type(5), "barrel");//"TOB"    
00051   buildSilicon(tec,tracker,theDetIdToEnum.type(6), "endcap");//"TEC"        
00052   buildGeomDet(tracker);//"GeomDet"
00053   return tracker;
00054 }
00055 
00056 void TrackerGeomBuilderFromGeometricDet::buildPixel(std::vector<const GeometricDet*>  const & gdv, 
00057                                                     TrackerGeometry* tracker,
00058                                                     GeomDetType::SubDetector& det,
00059                                                     const std::string& part){ 
00060 
00061   static std::map<std::string,PixelGeomDetType*> detTypeMap;
00062 
00063   for(u_int32_t i=0; i<gdv.size(); i++){
00064 
00065     std::string const & detName = gdv[i]->name();
00066     if (detTypeMap.find(detName) == detTypeMap.end()) {
00067 
00068       PixelTopology* t = 
00069         theTopologyBuilder->buildPixel(gdv[i]->bounds(),
00070                                        gdv[i]->pixROCRows(),
00071                                        gdv[i]->pixROCCols(),
00072                                        gdv[i]->pixROCx(),
00073                                        gdv[i]->pixROCy(),
00074                                        part);
00075       
00076       detTypeMap[detName] = new PixelGeomDetType(t,detName,det);
00077       tracker->addType(detTypeMap[detName]);
00078     }
00079 
00080     PlaneBuilderFromGeometricDet::ResultType plane = buildPlaneWithMaterial(gdv[i]);
00081     GeomDetUnit* temp =  new PixelGeomDetUnit(&(*plane),detTypeMap[detName],gdv[i]);
00082 
00083     tracker->addDetUnit(temp);
00084     tracker->addDetUnitId(gdv[i]->geographicalID());
00085   }
00086 }
00087 
00088 void TrackerGeomBuilderFromGeometricDet::buildSilicon(std::vector<const GeometricDet*>  const & gdv, 
00089                                                       TrackerGeometry* tracker,
00090                                                       GeomDetType::SubDetector& det,
00091                                                       const std::string& part)
00092 { 
00093   static std::map<std::string,StripGeomDetType*> detTypeMap;
00094   
00095   for(u_int32_t i=0;i<gdv.size();i++){
00096 
00097     std::string const & detName = gdv[i]->name();
00098     if (detTypeMap.find(detName) == detTypeMap.end()) {
00099 
00100        StripTopology* t =
00101         theTopologyBuilder->buildStrip(gdv[i]->bounds(),
00102                                        gdv[i]->siliconAPVNum(),
00103                                        part);
00104       detTypeMap[detName] = new  StripGeomDetType( t,detName,det,
00105                                                    gdv[i]->stereo());
00106       tracker->addType(detTypeMap[detName]);
00107     }
00108      
00109     StripSubdetector sidet( gdv[i]->geographicalID());
00110     double scale  = (sidet.partnerDetId()) ? 0.5 : 1.0 ;        
00111 
00112     PlaneBuilderFromGeometricDet::ResultType plane = buildPlaneWithMaterial(gdv[i],scale);  
00113     GeomDetUnit* temp = new StripGeomDetUnit(&(*plane), detTypeMap[detName],gdv[i]);
00114     
00115     tracker->addDetUnit(temp);
00116     tracker->addDetUnitId(gdv[i]->geographicalID());
00117   }  
00118 }
00119 
00120 
00121 void TrackerGeomBuilderFromGeometricDet::buildGeomDet(TrackerGeometry* tracker){
00122   PlaneBuilderForGluedDet gluedplaneBuilder;
00123   std::vector<GeomDetUnit*> const & gdu= tracker->detUnits();
00124   std::vector<DetId> const & gduId = tracker->detUnitIds();
00125 
00126   for(u_int32_t i=0;i<gdu.size();i++){
00127     StripSubdetector sidet( gduId[i].rawId());
00128     tracker->addDet((GeomDet*) gdu[i]);
00129     tracker->addDetId(gduId[i]);      
00130     if(sidet.glued()!=0&&sidet.stereo()==1){
00131       int partner_pos=-1;
00132       for(u_int32_t jj=0;jj<gduId.size();jj++){
00133         if(sidet.partnerDetId()== gduId[jj]) {
00134           partner_pos=jj;
00135           break;
00136         }
00137       }
00138       const GeomDetUnit* dus = gdu[i];
00139       if(partner_pos==-1){
00140         throw cms::Exception("Configuration") <<"No partner detector found \n"
00141                                         <<"There is a problem on Tracker geometry configuration\n";
00142       }
00143       const GeomDetUnit* dum = gdu[partner_pos];
00144       std::vector<const GeomDetUnit *> glued(2);
00145       glued[0]=dum;
00146       glued[1]=dus;
00147       PlaneBuilderForGluedDet::ResultType plane = gluedplaneBuilder.plane(glued);
00148       GluedGeomDet* gluedDet = new GluedGeomDet(&(*plane),dum,dus);
00149       tracker->addDet((GeomDet*) gluedDet);
00150       tracker->addDetId(DetId(sidet.glued()));
00151     }
00152   }
00153 }
00154 
00155 
00156 // std::string TrackerGeomBuilderFromGeometricDet::getString(const std::string & s, DDExpandedView* ev) const
00157 // {
00158 //     DDValue val(s);
00159 //     vector<const DDsvalues_type *> result;
00160 //     ev->specificsV(result);
00161 //     vector<const DDsvalues_type *>::iterator it = result.begin();
00162 //     bool foundIt = false;
00163 //     for (; it != result.end(); ++it)
00164 //     {
00165 //      foundIt = DDfetch(*it,val);
00166 //      if (foundIt) break;
00167 
00168 //     }    
00169 //     if (foundIt)
00170 //     { 
00171 //      const std::vector<std::string> & temp = val.strings(); 
00172 //      if (temp.size() != 1)
00173 //      {
00174 //        throw cms::Exception("Configuration") << "I need 1 "<< s << " tags";
00175 //      }
00176 //      return temp[0]; 
00177 //     }
00178 //     return "NotFound";
00179 // }
00180 
00181 // double TrackerGeomBuilderFromGeometricDet::getDouble(const std::string & s,  DDExpandedView* ev) const 
00182 // {
00183 //   DDValue val(s);
00184 //   vector<const DDsvalues_type *> result;
00185 //   ev->specificsV(result);
00186 //   vector<const DDsvalues_type *>::iterator it = result.begin();
00187 //   bool foundIt = false;
00188 //   for (; it != result.end(); ++it)
00189 //     {
00190 //       foundIt = DDfetch(*it,val);
00191 //       if (foundIt) break;
00192 //     }    
00193 //   if (foundIt)
00194 //     { 
00195 //       const std::vector<std::string> & temp = val.strings(); 
00196 //       if (temp.size() != 1)
00197 //      {
00198 //        throw cms::Exception("Configuration") << "I need 1 "<< s << " tags";
00199 //      }
00200 //       return double(atof(temp[0].c_str())); 
00201 //     }
00202 //   return 0;
00203 // }
00204 
00205 PlaneBuilderFromGeometricDet::ResultType
00206 TrackerGeomBuilderFromGeometricDet::buildPlaneWithMaterial(const GeometricDet* gd,
00207                                                            double scale) const
00208 {
00209   PlaneBuilderFromGeometricDet planeBuilder;
00210   PlaneBuilderFromGeometricDet::ResultType plane = planeBuilder.plane(gd);  
00211   //
00212   // set medium properties (if defined)
00213   //
00214   plane->setMediumProperties(MediumProperties(gd->radLength()*scale,gd->xi()*scale));
00215 
00216   return plane;
00217 }

Generated on Tue Jun 9 17:37:33 2009 for CMSSW by  doxygen 1.5.4