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 temp |= (((in)->components())[i]->geographicalID().rawId() << m_layerNumberPXB );
00121 break;
00122 }
00123
00124 case 2:
00125 {
00126 temp |= (((in)->components())[i]->geographicalID().rawId() << 16 );
00127 break;
00128 }
00129
00130 case 3:
00131 {
00132 temp |= (((in)->components())[i]->geographicalID().rawId() << 14);
00133 break;
00134 }
00135
00136
00137 case 4:
00138 {
00139 temp |= (((in)->components())[i]->geographicalID().rawId() << 11);
00140 break;
00141 }
00142
00143
00144 case 5:
00145 {
00146 temp |= (((in)->components())[i]->geographicalID().rawId() << 14);
00147 break;
00148 }
00149
00150
00151 case 6:
00152 {
00153 temp |= (((in)->components())[i]->geographicalID().rawId() << 14);
00154 break;
00155 }
00156
00157
00158 default:
00159 {
00160
00161 }
00162
00163
00164 }
00165
00166 ((in)->components())[i]->setGeographicalID( temp );
00167
00168
00169 iterate(((in)->components())[i],level+1,((in)->components())[i]->geographicalID().rawId());
00170 }
00171
00172 break;
00173 }
00174
00175 case 2: {
00176
00177 for (uint32_t i=0;i<(in)->components().size();i++) {
00178
00179 switch (iSubDet) {
00180
00181
00182 case 1:
00183 {
00184 uint32_t temp = ID;
00185
00186 temp |= (((in)->components())[i]->geographicalID().rawId()<<8);
00187 ((in)->components())[i]->setGeographicalID(temp);
00188 break;
00189 }
00190
00191
00192 case 2:
00193 {
00194 uint32_t temp = ID;
00195
00196 temp |= (((in)->components())[i]->geographicalID().rawId()<<8);
00197 ((in)->components())[i]->setGeographicalID(temp);
00198 break;
00199 }
00200
00201
00202 case 3:
00203 {
00204 uint32_t temp = ID;
00205
00206 temp |= (((in)->components())[i]->geographicalID().rawId()<<4);
00207 ((in)->components())[i]->setGeographicalID(temp);
00208 break;
00209 }
00210
00211
00212 case 4:
00213 {
00214 uint32_t temp = ID;
00215
00216 temp |= (((in)->components())[i]->geographicalID().rawId()<<9);
00217 ((in)->components())[i]->setGeographicalID(DetId(temp));
00218 break;
00219 }
00220
00221
00222 case 5:
00223 {
00224 uint32_t temp = ID;
00225
00226 temp |= (((in)->components())[i]->geographicalID().rawId()<<5);
00227 ((in)->components())[i]->setGeographicalID(temp);
00228 break;
00229 }
00230
00231
00232 case 6:
00233 {
00234 uint32_t temp = ID;
00235
00236 temp |= (((in)->components())[i]->geographicalID().rawId()<<8);
00237 ((in)->components())[i]->setGeographicalID(temp);
00238 break;
00239 }
00240
00241
00242 default:
00243 {
00244
00245 }
00246
00247
00248 }
00249
00250
00251 iterate(((in)->components())[i],level+1,((in)->components())[i]->geographicalID().rawId());
00252 }
00253
00254 break;
00255 }
00256
00257
00258 case 3:
00259 {
00260 for (uint32_t i=0;i<(in)->components().size();i++) {
00261
00262 switch (iSubDet) {
00263
00264
00265 case 6:
00266 {
00267
00268 uint32_t temp = ID;
00269 temp |= (((in)->components())[i]->geographicalID().rawId()<<5);
00270 ((in)->components())[i]->setGeographicalID(temp);
00271 break;
00272 }
00273
00274
00275 default:
00276 {
00277 uint32_t temp = ID;
00278 temp |= (((in)->components())[i]->geographicalID().rawId()<<2);
00279 ((in)->components())[i]->setGeographicalID(temp);
00280 }
00281
00282
00283 }
00284
00285
00286 iterate(((in)->components())[i],level+1,((in)->components())[i]->geographicalID().rawId());
00287
00288 }
00289
00290 break;
00291 }
00292
00293
00294 case 4:
00295 {
00296
00297 for (uint32_t i=0;i<(in)->components().size();i++) {
00298
00299 switch (iSubDet) {
00300
00301
00302 case 6:
00303 {
00304
00305 uint32_t temp = ID;
00306 temp |= (((in)->components())[i]->geographicalID().rawId()<<2);
00307 ((in)->components())[i]->setGeographicalID(temp);
00308
00309 iterate(((in)->components())[i],level+1,((in)->components())[i]->geographicalID().rawId());
00310 break;
00311 }
00312
00313
00314 default:
00315 {
00316 for (uint32_t i=0;i<(in)->components().size();i++) {
00317 uint32_t temp = ID;
00318 temp |= (((in)->components())[i]->geographicalID().rawId());
00319 ((in)->components())[i]->setGeographicalID(temp);
00320 }
00321 }
00322
00323
00324 }
00325
00326 }
00327
00328 break;
00329 }
00330
00331
00332 case 5:
00333 {
00334
00335 for (uint32_t i=0;i<(in)->components().size();i++) {
00336 uint32_t temp = ID;
00337 temp |= (((in)->components())[i]->geographicalID().rawId());
00338 ((in)->components())[i]->setGeographicalID(temp);
00339 }
00340 break;
00341 }
00342
00343
00344 default:
00345 {
00346 cms::Exception("LogicError") <<" CmsTrackerDetIdBuilder invalid level "<< level;
00347 }
00348
00349
00350 }
00351
00352 return;
00353
00354 }
00355