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