Go to the documentation of this file.00001 #include "Geometry/TrackerNumberingBuilder/plugins/CmsTrackerLayerBuilder.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/CmsTrackerStringBuilder.h"
00006 #include "Geometry/TrackerNumberingBuilder/plugins/CmsTrackerRodBuilder.h"
00007 #include "Geometry/TrackerNumberingBuilder/plugins/CmsTrackerLadderBuilder.h"
00008 #include "Geometry/TrackerNumberingBuilder/plugins/TrackerStablePhiSort.h"
00009 #include "DataFormats/DetId/interface/DetId.h"
00010 #include "FWCore/MessageLogger/interface/MessageLogger.h"
00011 #include <vector>
00012
00013 #include <bitset>
00014
00015 void CmsTrackerLayerBuilder::buildComponent(DDFilteredView& fv, GeometricDet* g, std::string s){
00016
00017 CmsTrackerStringBuilder theCmsTrackerStringBuilder ;
00018 CmsTrackerRodBuilder theCmsTrackerRodBuilder;
00019 CmsTrackerLadderBuilder theCmsTrackerLadderBuilder;
00020
00021 GeometricDet * subdet = new GeometricDet(&fv,theCmsTrackerStringToEnum.type(ExtractStringFromDDD::getString(s,&fv)));
00022 switch (theCmsTrackerStringToEnum.type(ExtractStringFromDDD::getString(s,&fv))){
00023 case GeometricDet::strng:
00024 theCmsTrackerStringBuilder.build(fv,subdet,s);
00025 break;
00026 case GeometricDet::rod:
00027 theCmsTrackerRodBuilder.build(fv,subdet,s);
00028 break;
00029 case GeometricDet::ladder:
00030 theCmsTrackerLadderBuilder.build(fv,subdet,s);
00031 break;
00032 default:
00033 edm::LogError("CmsTrackerLayerBuilder")<<" ERROR - I was expecting a String, Rod or Ladder, I got a "<<ExtractStringFromDDD::getString(s,&fv);
00034
00035 }
00036 g->addComponent(subdet);
00037
00038 }
00039
00040 void CmsTrackerLayerBuilder::sortNS(DDFilteredView& fv, GeometricDet* det){
00041
00042 GeometricDet::GeometricDetContainer comp = det->components();
00043
00044
00045
00046
00047
00048
00049 if(det->components().front()->type()== GeometricDet::strng){
00050 float layerRadius = (det->params()[2]+det->params()[1])/2.;
00051
00052 GeometricDet::GeometricDetContainer neg;
00053 GeometricDet::GeometricDetContainer pos;
00054 GeometricDet::GeometricDetContainer extneg;
00055 GeometricDet::GeometricDetContainer intneg;
00056 GeometricDet::GeometricDetContainer extpos;
00057 GeometricDet::GeometricDetContainer intpos;
00058 neg.clear();
00059 pos.clear();
00060 extneg.clear();
00061 intneg.clear();
00062 extpos.clear();
00063 intpos.clear();
00064
00065
00066 for(GeometricDet::GeometricDetContainer::iterator i=comp.begin();i!=comp.end();i++){
00067 if((*i)->translation().z()<0.){
00068 neg.push_back(*i);
00069 }else{
00070 pos.push_back(*i);
00071 }
00072 }
00073
00074 for(GeometricDet::GeometricDetContainer::iterator i=neg.begin();i!=neg.end();i++){
00075 double rPos = (*i)->translation().Rho();
00076 if(rPos > layerRadius ){
00077 extneg.push_back(*i);
00078 }else{
00079 intneg.push_back(*i);
00080 }
00081 }
00082
00083 for(GeometricDet::GeometricDetContainer::iterator i=pos.begin();i!=pos.end();i++){
00084 double rPos = (*i)->translation().Rho();
00085 if(rPos > layerRadius ){
00086 extpos.push_back(*i);
00087 }else{
00088 intpos.push_back(*i);
00089 }
00090 }
00091
00092 TrackerStablePhiSort(extneg.begin(), extneg.end(), ExtractPhi());
00093 TrackerStablePhiSort(extpos.begin(), extpos.end(), ExtractPhi());
00094 TrackerStablePhiSort(intneg.begin(), intneg.end(), ExtractPhi());
00095 TrackerStablePhiSort(intpos.begin(), intpos.end(), ExtractPhi());
00096
00097 for(uint32_t i=0;i<intneg.size();i++){
00098 uint32_t temp=i+1;
00099 temp|=(1<<8);
00100 temp|=(1<<6);
00101 intneg[i]->setGeographicalID(DetId(temp));
00102 }
00103
00104 for(uint32_t i=0;i<extneg.size();i++){
00105 uint32_t temp=i+1;
00106 temp|=(1<<8);
00107 temp|=(2<<6);
00108 extneg[i]->setGeographicalID(DetId(temp));
00109 }
00110
00111 for(uint32_t i=0;i<intpos.size();i++){
00112 uint32_t temp=i+1;
00113 temp|=(2<<8);
00114 temp|=(1<<6);
00115 intpos[i]->setGeographicalID(DetId(temp));
00116 }
00117
00118 for(uint32_t i=0;i<extpos.size();i++){
00119 uint32_t temp=i+1;
00120 temp|=(2<<8);
00121 temp|=(2<<6);
00122 extpos[i]->setGeographicalID(DetId(temp));
00123 }
00124
00125
00126 det->clearComponents();
00127 det->addComponents(intneg);
00128 det->addComponents(extneg);
00129 det->addComponents(intpos);
00130 det->addComponents(extpos);
00131
00132 }else if(det->components().front()->type()== GeometricDet::rod){
00133 GeometricDet::GeometricDetContainer neg;
00134 GeometricDet::GeometricDetContainer pos;
00135 neg.clear();
00136 pos.clear();
00137
00138 for(GeometricDet::GeometricDetContainer::iterator i=comp.begin();i!=comp.end();i++){
00139 if((*i)->translation().z()<0.){
00140 neg.push_back(*i);
00141 }else{
00142 pos.push_back(*i);
00143 }
00144 }
00145
00146 TrackerStablePhiSort(neg.begin(), neg.end(), ExtractPhi());
00147 TrackerStablePhiSort(pos.begin(), pos.end(), ExtractPhi());
00148
00149 for(uint32_t i=0; i<neg.size();i++){
00150 uint32_t temp = i+1;
00151 temp|=(1<<7);
00152 neg[i]->setGeographicalID(DetId(temp));
00153 }
00154
00155 for(uint32_t i=0; i<pos.size();i++){
00156 uint32_t temp = i+1;
00157 temp|=(2<<7);
00158 pos[i]->setGeographicalID(DetId(temp));
00159 }
00160
00161 det->clearComponents();
00162 det->addComponents(neg);
00163 det->addComponents(pos);
00164
00165 }else if(det->components().front()->type()== GeometricDet::ladder){
00166
00167 TrackerStablePhiSort(comp.begin(), comp.end(), ExtractPhi());
00168
00169 for(uint32_t i=0; i<comp.size();i++){
00170 comp[i]->setGeographicalID(DetId(i+1));
00171 }
00172
00173 det->clearComponents();
00174 det->addComponents(comp);
00175 }else{
00176 edm::LogError("CmsTrackerLayerBuilder")<<"ERROR - wrong SubDet to sort..... "<<det->components().front()->type();
00177 }
00178
00179 }
00180