CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_3_0/src/Geometry/EcalCommonData/src/EcalPreshowerNumberingScheme.cc

Go to the documentation of this file.
00001 
00002 // File: EcalPreshowerNumberingScheme.cc
00003 // Description: Numbering scheme for preshower detector
00005 
00006 #include "Geometry/EcalCommonData/interface/EcalPreshowerNumberingScheme.h"
00007 #include "DataFormats/EcalDetId/interface/ESDetId.h"
00008 
00009 #include <iostream>
00010 using namespace std;
00011 
00012 EcalPreshowerNumberingScheme::EcalPreshowerNumberingScheme() : 
00013   EcalNumberingScheme() {
00014 
00015   // For SFLX2a, we use copy# 1-3 
00016   int vL2ax[3] = { 4,  6, 10};
00017   int vL2ay[3] = {29, 31, 35};
00018   // For SFLX2b, we use copy# 1
00019   int vL2bx[1] = {2};
00020   int vL2by[1] = {25};
00021   // For SFLX3a, we use copy# 4-6
00022   int vL3ax[3] = {30, 34, 36};
00023   int vL3ay[3] = {35, 31, 29};
00024   // For SFLX3b, we use copy# 2
00025   int vL3bx[1] = {38};
00026   int vL3by[1] = {25};
00027   // For SFLX1a, we use odd number in copy# 1-52
00028   int vL1ax[26] = { 2,  4,  4,  8,  8,  8,  8, 10, 12, 12, 14, 14, 20, 20, 26, 26, 28, 28, 30, 32, 32, 32, 32, 36, 36, 38};
00029   int vL1ay[26] = {21, 25, 21, 33, 29, 25, 21, 21, 25, 21, 31, 27, 32, 28, 31, 27, 25, 21, 21, 33, 29, 25, 21, 25, 21, 21};
00030   // For SFLX1b, we use copy# 2
00031   int vL1bx[1] = {22};
00032   int vL1by[1] = {27};
00033   // For SFLX1c, we use copy# 1
00034   int vL1cx[1] = {18};
00035   int vL1cy[1] = {27};
00036   // For SFLX1d, we use copy# 2
00037   int vL1dx[1] = {26};
00038   int vL1dy[1] = {23};
00039   // For SFLX1e, we use copy# 1
00040   int vL1ex[1] = {14};
00041   int vL1ey[1] = {23};
00042   // For SFLX0a, we use odd number if copy# 1-46
00043   int vL0ax[23] = { 6,  6, 10, 10, 12, 12, 14, 16, 16, 18, 18, 20, 22, 22, 24, 24, 26, 28, 28, 30, 30, 34, 34};
00044   int vL0ay[23] = {26, 21, 30, 25, 34, 29, 35, 36, 31, 36, 31, 36, 36, 31, 36, 31, 35, 34, 29, 30, 25, 26, 21};
00045   // For SFL0b, we use copy# 2
00046   int vL0bx[1] = {24};
00047   int vL0by[1] = {26};
00048   // For SFL0c, we use copy# 1
00049   int vL0cx[1] = {16};
00050   int vL0cy[1] = {26};
00051 
00052   for (int i=0; i<1; ++i) {
00053     L1bx[i] = vL1bx[i];
00054     L1by[i] = vL1by[i];
00055     L1cx[i] = vL1cx[i];
00056     L1cy[i] = vL1cy[i];
00057     L1dx[i] = vL1dx[i];
00058     L1dy[i] = vL1dy[i];
00059     L1ex[i] = vL1ex[i];
00060     L1ey[i] = vL1ey[i];
00061     L0bx[i] = vL0bx[i];
00062     L0by[i] = vL0by[i];
00063     L0cx[i] = vL0cx[i];
00064     L0cy[i] = vL0cy[i];
00065     L3bx[i] = vL3bx[i];
00066     L3by[i] = vL3by[i];
00067     L2bx[i] = vL2bx[i];
00068     L2by[i] = vL2by[i];
00069   }
00070 
00071   for (int i=0; i<3; ++i) {
00072     L3ax[i] = vL3ax[i];
00073     L3ay[i] = vL3ay[i];
00074     L2ax[i] = vL2ax[i];
00075     L2ay[i] = vL2ay[i];
00076   }
00077 
00078   for (int i=0; i<23; ++i) {
00079     L0ax[i] = vL0ax[i];
00080     L0ay[i] = vL0ay[i];
00081   }
00082 
00083   for (int i=0; i<26; ++i) {
00084     L1ax[i] = vL1ax[i];
00085     L1ay[i] = vL1ay[i];
00086   }
00087 
00088   edm::LogInfo("EcalGeom") << "Creating EcalPreshowerNumberingScheme";
00089 }
00090 
00091 EcalPreshowerNumberingScheme::~EcalPreshowerNumberingScheme() {
00092   edm::LogInfo("EcalGeom") << "Deleting EcalPreshowerNumberingScheme";
00093 }
00094 
00095 uint32_t EcalPreshowerNumberingScheme::getUnitID(const EcalBaseNumber& baseNumber) const  {
00096 
00097   int level = baseNumber.getLevels();
00098   uint32_t intIndex = 0; 
00099   if (level > 0) {
00100     
00101     // depth index - silicon layer 1-st or 2-nd
00102     int layer = 0;
00103     if(baseNumber.getLevelName(0) == "SFSX") {
00104       layer = 1;
00105     } else if (baseNumber.getLevelName(0) == "SFSY") {
00106       layer = 2;
00107     } else {
00108       edm::LogWarning("EcalGeom") << "EcalPreshowerNumberingScheme: Wrong name"
00109                                   << " of Presh. Si. Strip : " 
00110                                   << baseNumber.getLevelName(0);
00111     }
00112     
00113     // Z index +Z = 1 ; -Z = 2
00114     int zside   = baseNumber.getCopyNumber("EREG");
00115     zside=2*(1-zside)+1;
00116 
00117     // box number
00118     int box = baseNumber.getCopyNumber(2);
00119 
00120     int x=0,y=0,ix,iy,id;
00121     int mapX[10] ={0,0,0,0,0,0,0,0,0,0};  int mapY[10] ={0,0,0,0,0,0,0,0,0,0};
00122     std::string ladd = baseNumber.getLevelName(3);
00123     int ladd_copy = baseNumber.getCopyNumber(3);
00124     
00125     if(ladd=="SFLX0a" || ladd=="SFLY0a" ) { 
00126       mapX[5] = mapX[6] = mapX[7] = mapX[8] = mapX[9] = 1; 
00127       mapY[0] = 0; mapY[1] = 1; mapY[2] = 2; mapY[3] = 3; mapY[4] = 4; 
00128       mapY[5] = 0; mapY[6] = 1; mapY[7] = 2;  mapY[8] = 3;  mapY[9] = 4; 
00129 
00130       id = (int) ((float)ladd_copy/2+0.5);
00131 
00132       x = L0ax[id-1] + mapX[box-1000-1];
00133       y = L0ay[id-1] + mapY[box-1000-1];    
00134 
00135       if ((ladd_copy%2) == 0) {
00136         if (mapX[box-1000-1]==0) x += 1;
00137         else if (mapX[box-1000-1]==1) x -= 1; 
00138         y = 41 - y;
00139       }
00140     }
00141     if(ladd=="SFLX0b" || ladd=="SFLY0b") { 
00142       mapX[4] = mapX[5] = mapX[6] = mapX[7] = mapX[8] = 1; 
00143       mapY[0] = 1; mapY[1] = 2; mapY[2] = 3; mapY[3] = 4; mapY[4] = 0; 
00144       mapY[5] = 1; mapY[6] = 2; mapY[7] = 3;  mapY[8] = 4;  mapY[9] = 0; 
00145 
00146       x = L0bx[0] + mapX[box-2000-1];
00147       y = L0by[0] + mapY[box-2000-1];    
00148 
00149       if (ladd_copy == 1) {
00150         x = 41 - x;
00151         y = 41 - y;
00152       }
00153     }
00154     if(ladd=="SFLX0c" || ladd=="SFLY0c") {
00155       mapX[5] = mapX[6] = mapX[7] = mapX[8] = 1; 
00156       mapY[0] = 0; mapY[1] = 1; mapY[2] = 2; mapY[3] = 3; mapY[4] = 4; 
00157       mapY[5] = 1; mapY[6] = 2; mapY[7] = 3;  mapY[8] = 4;  mapY[9] = 0; 
00158 
00159       x = L0cx[0] + mapX[box-3000-1];
00160       y = L0cy[0] + mapY[box-3000-1]; 
00161 
00162       if (ladd_copy == 2) {
00163         x = 41 - x;
00164         y = 41 - y;
00165       }
00166     }
00167     if(ladd=="SFLX1a" || ladd=="SFLY1a" ) {
00168       mapX[4] = mapX[5] = mapX[6] = mapX[7]  = 1; 
00169       mapY[0] = 0; mapY[1] = 1; mapY[2] = 2; mapY[3] = 3; mapY[4] = 0; 
00170       mapY[5] = 1; mapY[6] = 2; mapY[7] = 3;  mapY[8] = 0;  mapY[9] = 0; 
00171 
00172       id = (int) ((float)ladd_copy/2+0.5);
00173 
00174       x = L1ax[id-1] + mapX[box-4000-1];
00175       y = L1ay[id-1] + mapY[box-4000-1];    
00176 
00177       if ((ladd_copy%2) == 0) {
00178         if (mapX[box-4000-1]==0) x += 1;
00179         else if (mapX[box-4000-1]==1) x -= 1; 
00180         y = 41 - y;
00181       }
00182     }
00183     if(ladd=="SFLX1b" || ladd=="SFLY1b" ) {
00184       mapX[3] = mapX[4] = mapX[5] = mapX[6]  = 1; 
00185       mapY[0] = 1; mapY[1] = 2; mapY[2] = 3; mapY[3] = 0; mapY[4] = 1; 
00186       mapY[5] = 2; mapY[6] = 3; mapY[7] = 0;  mapY[8] = 0;  mapY[9] = 0; 
00187 
00188       x = L1bx[0] + mapX[box-5000-1];
00189       y = L1by[0] + mapY[box-5000-1];    
00190 
00191       if (ladd_copy == 1) {
00192         x = 41 - x;
00193         y = 41 - y;
00194       }
00195     }
00196     if(ladd=="SFLX1c" || ladd=="SFLY1c" ) {
00197       mapX[4] = mapX[5] = mapX[6]  = 1; 
00198       mapY[0] = 0; mapY[1] = 1; mapY[2] = 2; mapY[3] = 3; mapY[4] = 1; 
00199       mapY[5] = 2; mapY[6] = 3; mapY[7] = 0;  mapY[8] = 0;  mapY[9] = 0; 
00200 
00201       x = L1cx[0] + mapX[box-6000-1];
00202       y = L1cy[0] + mapY[box-6000-1];    
00203 
00204       if (ladd_copy == 2) {
00205         x = 41 - x;
00206         y = 41 - y;
00207       }
00208     }
00209     if(ladd=="SFLX1d" || ladd=="SFLY1d" ) {
00210       mapX[2] = mapX[3] = mapX[4] = mapX[5]  = 1; 
00211       mapY[0] = 2; mapY[1] = 3; mapY[2] = 0; mapY[3] = 1; mapY[4] = 2; 
00212       mapY[5] = 3; mapY[6] = 0; mapY[7] = 0;  mapY[8] = 0;  mapY[9] = 0; 
00213 
00214       x = L1dx[0] + mapX[box-7000-1];
00215       y = L1dy[0] + mapY[box-7000-1];    
00216 
00217       if (ladd_copy == 1) {
00218         x = 41 - x;
00219         y = 41 - y;
00220       }
00221     }
00222     if(ladd=="SFLX1e" || ladd=="SFLY1e") {
00223       mapX[4] = mapX[5] = 1; 
00224       mapY[0] = 0; mapY[1] = 1; mapY[2] = 2; mapY[3] = 3; mapY[4] = 2; 
00225       mapY[5] = 3; mapY[6] = 0; mapY[7] = 0; mapY[8] = 0; mapY[9] = 0; 
00226 
00227       x = L1ex[0] + mapX[box-8000-1];
00228       y = L1ey[0] + mapY[box-8000-1];    
00229 
00230       if (ladd_copy == 2) {
00231         x = 41 - x;
00232         y = 41 - y;
00233       }
00234     }
00235     if(ladd=="SFLX3a" || ladd=="SFLY3a" ) {
00236       mapX[4] = mapX[5] = mapX[6] = 1; 
00237       mapY[0] = 0; mapY[1] = 1; mapY[2] = 2; mapY[3] = 3; mapY[4] = 0; 
00238       mapY[5] = 1; mapY[6] = 2; mapY[7] = 0; mapY[8] = 0; mapY[9] = 0; 
00239 
00240       id = (ladd_copy>3)? ladd_copy-3 : 4-ladd_copy;     
00241 
00242       x = L3ax[id-1] + mapX[box-9000-1];
00243       y = L3ay[id-1] + mapY[box-9000-1];    
00244 
00245       if (ladd_copy<4) {
00246         x = 41 - x;
00247         y = 41 - y;
00248       }
00249     }
00250     if(ladd=="SFLX3b" || ladd=="SFLY3b") {
00251       mapX[4] = mapX[5] = 1; 
00252       mapY[0] = 0; mapY[1] = 1; mapY[2] = 2; mapY[3] = 3; mapY[4] = 0; 
00253       mapY[5] = 1; mapY[6] = 0; mapY[7] = 0; mapY[8] = 0; mapY[9] = 0; 
00254 
00255       x = L3bx[0] + mapX[box-11000-1];
00256       y = L3by[0] + mapY[box-11000-1];
00257 
00258       if (ladd_copy == 1) {
00259         x = 41 - x;
00260         y = 41 - y;
00261       }  
00262     }
00263     if(ladd=="SFLX2a" || ladd=="SFLY2a") {
00264       mapX[3] = mapX[4] = mapX[5] = mapX[6]  = 1; 
00265       mapY[0] = 0; mapY[1] = 1; mapY[2] = 2; mapY[3] = 0; mapY[4] = 1; 
00266       mapY[5] = 2; mapY[6] = 3; mapY[7] = 0; mapY[8] = 0; mapY[9] = 0; 
00267 
00268       id = (ladd_copy>3)? 7-ladd_copy : ladd_copy;     
00269 
00270       x = L2ax[id-1] + mapX[box-10000-1];
00271       y = L2ay[id-1] + mapY[box-10000-1];
00272 
00273       if (ladd_copy>3) {
00274         x = 41 - x;
00275         y = 41 - y;
00276       }  
00277     }
00278     if(ladd=="SFLX2b" || ladd=="SFLY2b") {
00279       mapX[2] = mapX[3] = mapX[4] = mapX[5]  = 1;             
00280       mapY[0] = 0; mapY[1] = 1; mapY[2] = 0; mapY[3] = 1; mapY[4] = 2; 
00281       mapY[5] = 3; mapY[6] = 0; mapY[7] = 0; mapY[8] = 0; mapY[9] = 0; 
00282 
00283       x = L2bx[0] + mapX[box-12000-1];
00284       y = L2by[0] + mapY[box-12000-1];
00285 
00286       if (ladd_copy == 2) {
00287         x = 41 - x;
00288         y = 41 - y;
00289       }  
00290     }
00291        
00292     if (zside<0 && layer == 1) x = 41 - x;
00293 
00294     ix = x;
00295     iy = y;
00296 
00297     if (layer == 2) {
00298       x = (zside>0) ? iy : 41 - iy; 
00299       y = 41 - ix;
00300     }
00301 
00302     // strip number inside wafer
00303     int strip = baseNumber.getCopyNumber(0);
00304     
00305     if (layer == 1) {
00306       if (zside>0 && y<=20) 
00307         strip = 33 - strip;
00308       else if (zside<0 && y>20)
00309         strip = 33 - strip;
00310     } else if (layer == 2) {
00311       if (zside>0 && x<=20) 
00312         strip = 33 - strip;
00313       else if (zside<0 && x>20)
00314         strip = 33 -strip;
00315     }
00316     
00317     intIndex =  ESDetId(strip, x, y, layer, zside).rawId(); 
00318     
00319     LogDebug("EcalGeom") << "EcalPreshowerNumberingScheme : zside "<<zside<<" Ladd "<< ladd << " ladd_copy: "<<ladd_copy<<" box "<<box<<" x "<<x<<" y "<<y<<" layer "<<layer<<" strip " << strip<<" UnitID 0x" << std::hex << intIndex << std::dec;
00320     
00321     for (int ich = 0; ich < level; ich++) {
00322       LogDebug("EcalGeom") << "Name = " << baseNumber.getLevelName(ich) 
00323                            << " copy = " << baseNumber.getCopyNumber(ich);
00324     }
00325   }
00326   
00327   return intIndex;
00328 }
00329