00001 #include "Geometry/TrackerNumberingBuilder/plugins/CmsTrackerWheelBuilder.h"
00002 #include "DetectorDescription/Core/interface/DDFilteredView.h"
00003 #include "Geometry/TrackerNumberingBuilder/interface/GeometricDet.h"
00004 #include "Geometry/TrackerNumberingBuilder/plugins/ExtractStringFromDDD.h"
00005 #include "DataFormats/DetId/interface/DetId.h"
00006 #include "Geometry/TrackerNumberingBuilder/plugins/CmsTrackerRingBuilder.h"
00007 #include "Geometry/TrackerNumberingBuilder/plugins/CmsTrackerPetalBuilder.h"
00008 #include "Geometry/TrackerNumberingBuilder/plugins/TrackerStablePhiSort.h"
00009 #include "FWCore/MessageLogger/interface/MessageLogger.h"
00010 #include<vector>
00011
00012 #include <bitset>
00013
00014 void CmsTrackerWheelBuilder::buildComponent(DDFilteredView& fv, GeometricDet* g, std::string s){
00015 CmsTrackerRingBuilder theCmsTrackerRingBuilder ;
00016 CmsTrackerPetalBuilder theCmsTrackerPetalBuilder ;
00017
00018 GeometricDet * subdet = new GeometricDet(&fv,theCmsTrackerStringToEnum.type(ExtractStringFromDDD::getString(s,&fv)));
00019 switch (theCmsTrackerStringToEnum.type(ExtractStringFromDDD::getString(s,&fv))){
00020 case GeometricDet::ring:
00021 theCmsTrackerRingBuilder.build(fv,subdet,s);
00022 break;
00023 case GeometricDet::petal:
00024 theCmsTrackerPetalBuilder.build(fv,subdet,s);
00025 break;
00026 default:
00027 edm::LogError("CmsTrackerWheelBuilder")<<" ERROR - I was expecting a Ring or Petal, I got a "<<ExtractStringFromDDD::getString(s,&fv);
00028 }
00029 g->addComponent(subdet);
00030 }
00031
00032 void CmsTrackerWheelBuilder::sortNS(DDFilteredView& fv, GeometricDet* det){
00033 GeometricDet::GeometricDetContainer comp = det->components();
00034
00035 if(comp.size()){
00036 if(comp.front()->type()==GeometricDet::petal){
00037 GeometricDet::GeometricDetContainer compfw;
00038 GeometricDet::GeometricDetContainer compbw;
00039 compfw.clear();
00040 compbw.clear();
00041 for(uint32_t i=0; i<comp.size();i++){
00042 if(fabs(comp[i]->translation().z())<fabs(det->translation().z())){
00043 compfw.push_back(comp[i]);
00044 }else{
00045 compbw.push_back(comp[i]);
00046 }
00047 }
00048
00049 TrackerStablePhiSort(compfw.begin(), compfw.end(), ExtractPhiModule());
00050 TrackerStablePhiSort(compbw.begin(), compbw.end(), ExtractPhiModule());
00051
00052
00053
00054
00055
00056
00057 for(uint32_t i=0; i<compbw.size(); i++){
00058 uint32_t temp = i+1;
00059 temp|=(1<<4);
00060 compbw[i]->setGeographicalID(DetId(temp));
00061 }
00062 for(uint32_t i=0; i<compfw.size(); i++){
00063 uint32_t temp = i+1;
00064 temp|=(2<<4);
00065 compfw[i]->setGeographicalID(DetId(temp));
00066 }
00067
00068 det->clearComponents();
00069 det->addComponents(compfw);
00070 det->addComponents(compbw);
00071
00072 }else{
00073 std::stable_sort(comp.begin(),comp.end(),LessR_module());
00074
00075
00076
00077 for(uint32_t i=0; i<comp.size(); i++){
00078 comp[i]->setGeographicalID(DetId(i+1));
00079 }
00080
00081 det->clearComponents();
00082 det->addComponents(comp);
00083 }
00084 }else{
00085 edm::LogError("CmsTrackerWheelBuilder")<<"Where are the Petals or Rings?";
00086 }
00087
00088 }
00089
00090
00091
00092