00001 #include "CondFormats/SiPixelObjects/interface/FrameConversion.h" 00002 #include "DataFormats/SiPixelDetId/interface/PixelBarrelName.h" 00003 #include "DataFormats/SiPixelDetId/interface/PixelEndcapName.h" 00004 #include "CondFormats/SiPixelObjects/interface/LocalPixel.h" 00005 00006 #include "FWCore/MessageLogger/interface/MessageLogger.h" 00007 00008 using namespace std; 00009 using namespace edm; 00010 using namespace sipixelobjects; 00011 00012 FrameConversion::FrameConversion( const PixelBarrelName & name, int rocIdInDetUnit) 00013 { 00014 int slopeRow =0; 00015 int slopeCol = 0; 00016 int rowOffset = 0; 00017 int colOffset = 0; 00018 if (name.isHalfModule() ) { 00019 slopeRow = -1; 00020 slopeCol = 1; 00021 rowOffset = LocalPixel::numRowsInRoc-1; 00022 colOffset = rocIdInDetUnit * LocalPixel::numColsInRoc; 00023 } else { 00024 if (rocIdInDetUnit <8) { 00025 slopeRow = -1; 00026 slopeCol = 1; 00027 rowOffset = 2*LocalPixel::numRowsInRoc-1; 00028 colOffset = rocIdInDetUnit * LocalPixel::numColsInRoc; 00029 } else { 00030 slopeRow = 1; 00031 slopeCol = -1; 00032 rowOffset = 0; 00033 colOffset = (16-rocIdInDetUnit)*LocalPixel::numColsInRoc-1; 00034 } 00035 } 00036 00037 // 00038 // FIX for negative barrel (not inverted modules) 00039 // 00040 PixelBarrelName::Shell shell = name.shell(); 00041 if (shell == PixelBarrelName::mO || shell == PixelBarrelName::mI) { 00042 slopeRow *= -1; 00043 slopeCol *= -1; 00044 colOffset = 8*LocalPixel::numColsInRoc-colOffset-1; 00045 switch(name.moduleType()) { 00046 //case(PixelModuleName::v1x8) : { rowOffset = LocalPixel::numRowsInRoc-rowOffset-1; break; } 00047 case(PixelModuleName::v1x8) : { 00048 slopeRow = -1; // d.k. 23/10/08 00049 slopeCol = 1; // d.k. 13/11/08 00050 //colOffset = rocIdInDetUnit * LocalPixel::numColsInRoc; // d.k. 13/11/08 00051 //colOffset = (8-rocIdInDetUnit) * LocalPixel::numColsInRoc -1; // d.k. 19/11/08 00052 colOffset = (8-rocIdInDetUnit-1) * LocalPixel::numColsInRoc; // d.k. 19/11/08 00053 //cout<<" FramConversion: "<<rocIdInDetUnit<<" "<<slopeRow<<" "<<slopeCol<<" "<<rowOffset<<" "<<colOffset<<endl; 00054 break; 00055 } 00056 default: { rowOffset = 2*LocalPixel::numRowsInRoc-rowOffset-1; break; } 00057 } 00058 } 00059 00060 theRowConversion = LinearConversion(rowOffset,slopeRow); 00061 theCollumnConversion = LinearConversion(colOffset, slopeCol); 00062 00063 } 00064 FrameConversion::FrameConversion( const PixelEndcapName & name, int rocIdInDetUnit) 00065 { 00066 int slopeRow =0; 00067 int slopeCol = 0; 00068 int rowOffset = 0; 00069 int colOffset = 0; 00070 00071 if (name.pannelName()==1) { 00072 if (name.plaquetteName()==1) { 00073 slopeRow = 1; 00074 slopeCol = -1; 00075 rowOffset = 0; 00076 colOffset = (1+rocIdInDetUnit)*LocalPixel::numColsInRoc-1; 00077 } else if (name.plaquetteName()==2) { 00078 if (rocIdInDetUnit <3) { 00079 slopeRow = -1; 00080 slopeCol = 1; 00081 rowOffset = 2*LocalPixel::numRowsInRoc-1; 00082 colOffset = rocIdInDetUnit*LocalPixel::numColsInRoc; 00083 } else { 00084 slopeRow = 1; 00085 slopeCol = -1; 00086 rowOffset = 0; 00087 colOffset = (6-rocIdInDetUnit)*LocalPixel::numColsInRoc-1; 00088 } 00089 } else if (name.plaquetteName()==3) { 00090 if (rocIdInDetUnit <4) { 00091 slopeRow = -1; 00092 slopeCol = 1; 00093 rowOffset = 2*LocalPixel::numRowsInRoc-1; 00094 colOffset = rocIdInDetUnit*LocalPixel::numColsInRoc; 00095 } else { 00096 slopeRow = 1; 00097 slopeCol = -1; 00098 rowOffset = 0; 00099 colOffset = (8-rocIdInDetUnit)*LocalPixel::numColsInRoc-1; 00100 } 00101 } else if (name.plaquetteName()==4) { 00102 slopeRow = -1; 00103 slopeCol = 1; 00104 rowOffset = LocalPixel::numRowsInRoc-1; 00105 colOffset = rocIdInDetUnit*LocalPixel::numColsInRoc; 00106 } 00107 } else { 00108 if (name.plaquetteName()==1) { 00109 if (rocIdInDetUnit <3) { 00110 slopeRow = 1; 00111 slopeCol = -1; 00112 rowOffset = 0; 00113 colOffset = (3-rocIdInDetUnit)*LocalPixel::numColsInRoc-1; 00114 } else { 00115 slopeRow = -1; 00116 slopeCol = 1; 00117 colOffset = (rocIdInDetUnit-3)*LocalPixel::numColsInRoc; 00118 rowOffset = 2*LocalPixel::numRowsInRoc-1; 00119 } 00120 } else if (name.plaquetteName()==2) { 00121 if (rocIdInDetUnit <4) { 00122 slopeRow = 1; 00123 slopeCol = -1; 00124 rowOffset = 0; 00125 colOffset = (4-rocIdInDetUnit)*LocalPixel::numColsInRoc-1; 00126 } else { 00127 slopeRow = -1; 00128 slopeCol = 1; 00129 colOffset = (rocIdInDetUnit-4)*LocalPixel::numColsInRoc; 00130 rowOffset = 2*LocalPixel::numRowsInRoc-1; 00131 } 00132 } else if (name.plaquetteName()==3) { 00133 if (rocIdInDetUnit <5) { 00134 slopeRow = 1; 00135 slopeCol = -1; 00136 rowOffset = 0; 00137 colOffset = (5-rocIdInDetUnit)*LocalPixel::numColsInRoc-1; 00138 } else { 00139 slopeRow = -1; 00140 slopeCol = 1; 00141 colOffset = (rocIdInDetUnit-5)*LocalPixel::numColsInRoc; 00142 rowOffset = 2*LocalPixel::numRowsInRoc-1; 00143 } 00144 } 00145 } 00146 00147 theRowConversion = LinearConversion(rowOffset,slopeRow); 00148 theCollumnConversion = LinearConversion(colOffset, slopeCol); 00149 }