Go to the documentation of this file.00001 #include "Geometry/TrackerNumberingBuilder/plugins/CmsTrackerDetIdBuilder.h"
00002 #include "Geometry/TrackerNumberingBuilder/interface/GeometricDet.h"
00003
00004 #include "FWCore/Utilities/interface/Exception.h"
00005
00006 #include "DataFormats/DetId/interface/DetId.h"
00007
00008 #include <iostream>
00009 #include <fstream>
00010 #include <sstream>
00011 #include <string>
00012 #include <bitset>
00013
00014
00015 CmsTrackerDetIdBuilder::CmsTrackerDetIdBuilder(){
00016 }
00017
00018 GeometricDet* CmsTrackerDetIdBuilder::buildId(GeometricDet* tracker){
00019
00020 DetId t(DetId::Tracker,0);
00021 tracker->setGeographicalID(t);
00022 iterate(tracker,0,tracker->geographicalID().rawId());
00023
00024 return tracker;
00025 }
00026
00027 void CmsTrackerDetIdBuilder::iterate(GeometricDet const * in, int level, unsigned int ID){
00028 std::bitset<32> binary_ID(ID);
00029
00030
00031 uint32_t mask = (7<<25);
00032 uint32_t iSubDet = ID & mask;
00033 iSubDet = iSubDet >> 25;
00034
00035
00036 switch (level) {
00037
00038
00039 case 0:
00040 {
00041
00042 for(uint32_t i=0; i<(in)->components().size();i++) {
00043 uint32_t jSubDet = ((in)->components())[i]->geographicalID().rawId();
00044 uint32_t temp = ID;
00045 temp |= (jSubDet<<25);
00046 ((in)->components())[i]->setGeographicalID(temp);
00047
00048 switch (jSubDet) {
00049
00050
00051 case 2:
00052 {
00053
00054 if( ((in)->components())[i]->translation().z()<0. ) {
00055 temp |= (1<<23);
00056 } else {
00057 temp |= (2<<23);
00058 }
00059 break;
00060 }
00061
00062
00063 case 4:
00064 {
00065 temp|= (0<<15);
00066 if( (((in)->components())[i])->components()[0]->translation().z()<0. ) {
00067 temp |= (1<<13);
00068 } else {
00069 temp |= (2<<13);
00070 }
00071 break;
00072 }
00073
00074
00075 case 6:
00076 {
00077 temp|= (0<<20);
00078 if( ((in)->components())[i]->translation().z()<0. ) {
00079 temp |= (1<<18);
00080 } else {
00081 temp |= (2<<18);
00082 }
00083 break;
00084 }
00085
00086
00087 default:
00088 {
00089
00090 }
00091
00092
00093 }
00094
00095 ((in)->components())[i]->setGeographicalID(DetId(temp));
00096
00097
00098 iterate(((in)->components())[i],level+1,((in)->components())[i]->geographicalID().rawId());
00099 }
00100 break;
00101 }
00102
00103
00104 case 1: {
00105
00106 for (uint32_t i=0;i<(in)->components().size();i++) {
00107 uint32_t temp = ID;
00108
00109 switch (iSubDet) {
00110
00111
00112 case 1:
00113 {
00114 temp |= (((in)->components())[i]->geographicalID().rawId()<<16);
00115 break;
00116 }
00117
00118
00119 case 2:
00120 {
00121 temp |= (((in)->components())[i]->geographicalID().rawId()<<16);
00122 break;
00123 }
00124
00125
00126 case 3:
00127 {
00128 temp |= (((in)->components())[i]->geographicalID().rawId()<<14);
00129 break;
00130 }
00131
00132
00133 case 4:
00134 {
00135 temp |= (((in)->components())[i]->geographicalID().rawId()<<11);
00136 break;
00137 }
00138
00139
00140 case 5:
00141 {
00142 temp |= (((in)->components())[i]->geographicalID().rawId()<<14);
00143 break;
00144 }
00145
00146
00147 case 6:
00148 {
00149 temp |= (((in)->components())[i]->geographicalID().rawId()<<14);
00150 break;
00151 }
00152
00153
00154 default:
00155 {
00156
00157 }
00158
00159
00160 }
00161
00162 ((in)->components())[i]->setGeographicalID(temp);
00163
00164
00165 iterate(((in)->components())[i],level+1,((in)->components())[i]->geographicalID().rawId());
00166 }
00167
00168 break;
00169 }
00170
00171
00172 case 2: {
00173
00174 for (uint32_t i=0;i<(in)->components().size();i++) {
00175
00176 switch (iSubDet) {
00177
00178
00179 case 1:
00180 {
00181 uint32_t temp = ID;
00182
00183 temp |= (((in)->components())[i]->geographicalID().rawId()<<8);
00184 ((in)->components())[i]->setGeographicalID(temp);
00185 break;
00186 }
00187
00188
00189 case 2:
00190 {
00191 uint32_t temp = ID;
00192
00193 temp |= (((in)->components())[i]->geographicalID().rawId()<<8);
00194 ((in)->components())[i]->setGeographicalID(temp);
00195 break;
00196 }
00197
00198
00199 case 3:
00200 {
00201 uint32_t temp = ID;
00202
00203 temp |= (((in)->components())[i]->geographicalID().rawId()<<4);
00204 ((in)->components())[i]->setGeographicalID(temp);
00205 break;
00206 }
00207
00208
00209 case 4:
00210 {
00211 uint32_t temp = ID;
00212
00213 temp |= (((in)->components())[i]->geographicalID().rawId()<<9);
00214 ((in)->components())[i]->setGeographicalID(DetId(temp));
00215 break;
00216 }
00217
00218
00219 case 5:
00220 {
00221 uint32_t temp = ID;
00222
00223 temp |= (((in)->components())[i]->geographicalID().rawId()<<5);
00224 ((in)->components())[i]->setGeographicalID(temp);
00225 break;
00226 }
00227
00228
00229 case 6:
00230 {
00231 uint32_t temp = ID;
00232
00233 temp |= (((in)->components())[i]->geographicalID().rawId()<<8);
00234 ((in)->components())[i]->setGeographicalID(temp);
00235 break;
00236 }
00237
00238
00239 default:
00240 {
00241
00242 }
00243
00244
00245 }
00246
00247
00248 iterate(((in)->components())[i],level+1,((in)->components())[i]->geographicalID().rawId());
00249 }
00250
00251 break;
00252 }
00253
00254
00255 case 3:
00256 {
00257 for (uint32_t i=0;i<(in)->components().size();i++) {
00258
00259 switch (iSubDet) {
00260
00261
00262 case 6:
00263 {
00264
00265 uint32_t temp = ID;
00266 temp |= (((in)->components())[i]->geographicalID().rawId()<<5);
00267 ((in)->components())[i]->setGeographicalID(temp);
00268 break;
00269 }
00270
00271
00272 default:
00273 {
00274 uint32_t temp = ID;
00275 temp |= (((in)->components())[i]->geographicalID().rawId()<<2);
00276 ((in)->components())[i]->setGeographicalID(temp);
00277 }
00278
00279
00280 }
00281
00282
00283 iterate(((in)->components())[i],level+1,((in)->components())[i]->geographicalID().rawId());
00284
00285 }
00286
00287 break;
00288 }
00289
00290
00291 case 4:
00292 {
00293
00294 for (uint32_t i=0;i<(in)->components().size();i++) {
00295
00296 switch (iSubDet) {
00297
00298
00299 case 6:
00300 {
00301
00302 uint32_t temp = ID;
00303 temp |= (((in)->components())[i]->geographicalID().rawId()<<2);
00304 ((in)->components())[i]->setGeographicalID(temp);
00305
00306 iterate(((in)->components())[i],level+1,((in)->components())[i]->geographicalID().rawId());
00307 break;
00308 }
00309
00310
00311 default:
00312 {
00313 for (uint32_t i=0;i<(in)->components().size();i++) {
00314 uint32_t temp = ID;
00315 temp |= (((in)->components())[i]->geographicalID().rawId());
00316 ((in)->components())[i]->setGeographicalID(temp);
00317 }
00318 }
00319
00320
00321 }
00322
00323 }
00324
00325 break;
00326 }
00327
00328
00329 case 5:
00330 {
00331
00332 for (uint32_t i=0;i<(in)->components().size();i++) {
00333 uint32_t temp = ID;
00334 temp |= (((in)->components())[i]->geographicalID().rawId());
00335 ((in)->components())[i]->setGeographicalID(temp);
00336 }
00337 break;
00338 }
00339
00340
00341 default:
00342 {
00343 cms::Exception("LogicError") <<" CmsTrackerDetIdBuilder invalid level "<< level;
00344 }
00345
00346
00347 }
00348
00349 return;
00350
00351 }
00352