CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_3_1/src/Geometry/TrackerNumberingBuilder/plugins/CmsTrackerDiskBuilder.cc

Go to the documentation of this file.
00001 #include "Geometry/TrackerNumberingBuilder/plugins/CmsTrackerDiskBuilder.h"
00002 #include "DetectorDescription/Core/interface/DDFilteredView.h"
00003 #include "Geometry/TrackerNumberingBuilder/interface/GeometricDet.h"
00004 #include "Geometry/TrackerNumberingBuilder/plugins/ExtractStringFromDDD.h"
00005 #include "Geometry/TrackerNumberingBuilder/plugins/CmsTrackerPanelBuilder.h"
00006 #include "Geometry/TrackerNumberingBuilder/plugins/TrackerStablePhiSort.h"
00007 #include "DataFormats/DetId/interface/DetId.h"
00008 #include "FWCore/MessageLogger/interface/MessageLogger.h"
00009 #include <vector>
00010 
00011 
00012 void CmsTrackerDiskBuilder::buildComponent(DDFilteredView& fv, GeometricDet* g, std::string s){
00013 
00014   CmsTrackerPanelBuilder   theCmsTrackerPanelBuilder;
00015   GeometricDet * subdet = new GeometricDet(&fv,theCmsTrackerStringToEnum.type(ExtractStringFromDDD::getString(s,&fv)));
00016 
00017   switch (theCmsTrackerStringToEnum.type(ExtractStringFromDDD::getString(s,&fv))){
00018   case GeometricDet::panel:
00019     theCmsTrackerPanelBuilder.build(fv,subdet,s);
00020     break;
00021   default:
00022     edm::LogError("CmsTrackerDiskBuilder")<<" ERROR - I was expecting a Panel, I got a "<<ExtractStringFromDDD::getString(s,&fv);   
00023   }  
00024   g->addComponent(subdet);
00025 }
00026 
00027 void CmsTrackerDiskBuilder::sortNS(DDFilteredView& fv, GeometricDet* det){
00028 
00029  GeometricDet::GeometricDetContainer & comp = det->components();
00030 
00031  switch(det->components().front()->type()){
00032  case GeometricDet::panel:
00033    TrackerStablePhiSort(comp.begin(),comp.end(), ExtractPhi());
00034    break;
00035  default:
00036    edm::LogError("CmsTrackerDiskBuilder")<<"ERROR - wrong SubDet to sort..... "<<det->components().front()->type();
00037  }
00038 
00039   GeometricDet::GeometricDetContainer zminpanels;  // Here z refers abs(z);
00040   GeometricDet::GeometricDetContainer zmaxpanels;   // So, zmin panel is always closer to ip.
00041 
00042   uint32_t  totalblade = comp.size()/2;
00043   if ( totalblade != 24 )
00044         edm::LogError("CmsTrackerDiskBuilder")<<"ERROR, The Total Number of Blade in one disk is "<<totalblade;
00045 
00046   zminpanels.reserve(totalblade);
00047   zmaxpanels.reserve(totalblade);
00048   for( uint32_t  j=0; j<totalblade ;j++)
00049   {
00050     if ( fabs( comp[2*j]->translation().z() ) > fabs( comp[ 2*j +1 ]->translation().z() ) ) {
00051          zmaxpanels.push_back(comp[2*j] );
00052          zminpanels.push_back(comp[2*j+1]);
00053 
00054     }else if ( fabs( comp[2*j]->translation().z() ) < fabs( comp[ 2*j +1 ]->translation().z() ) ) {
00055          zmaxpanels.push_back(comp[2*j+1] );
00056          zminpanels.push_back(comp[2*j]);
00057 
00058     }else {
00059        edm::LogWarning("CmsTrackerDiskBuilder")<<"WARNING - The Z of  both panels are equal! ";
00060     }
00061 
00062   }
00063 
00064   for ( uint32_t  fn=0; fn< zminpanels.size(); fn++) {
00065     uint32_t blade = fn+1;
00066     uint32_t panel = 1;
00067     uint32_t temp = (blade<<2) | panel;
00068     zminpanels[fn]->setGeographicalID(temp);
00069   }
00070   
00071   for (uint32_t  bn=0; bn< zmaxpanels.size(); bn++) {
00072     uint32_t blade = bn+1;
00073     uint32_t panel = 2;
00074     uint32_t temp = (blade<<2) | panel;
00075     zmaxpanels[bn]->setGeographicalID(temp);
00076   }
00077   
00078   det->clearComponents();
00079   
00080   det->addComponents(zminpanels);
00081   det->addComponents(zmaxpanels);
00082 }