![]() |
|
|||
File indexing completed on 2023-10-25 09:37:28
0001 #include "CondFormats/SiPixelObjects/interface/PixelROC.h" 0002 0003 #include "DataFormats/TrackerCommon/interface/PixelBarrelName.h" 0004 #include "DataFormats/TrackerCommon/interface/PixelEndcapName.h" 0005 #include "DataFormats/DetId/interface/DetId.h" 0006 0007 #include <sstream> 0008 #include <algorithm> 0009 using namespace std; 0010 using namespace sipixelobjects; 0011 0012 // Constructor with transformation frame initilization - NEVER CALLED 0013 PixelROC::PixelROC(uint32_t du, int idDU, int idLk) : theDetUnit(du), theIdDU(idDU), theIdLk(idLk) { 0014 initFrameConversion(); 0015 } 0016 0017 // // for testing, uses topology fot det id, it works but I cannot pass topology here 0018 // // not used 0019 // void PixelROC::initFrameConversion(const TrackerTopology *tt, bool phase1) { 0020 // const bool TEST = false; 0021 // if(phase1) { // phase1 0022 // bool isBarrel = PixelModuleName::isBarrel(theDetUnit); 0023 // int side = 0; 0024 // if(isBarrel) { 0025 // // Barrel Z-index=1,8 0026 // if((tt->pxbModule(theDetUnit))<5) side=-1; 0027 // else side=1; 0028 // if(TEST) { 0029 // // phase0 code 0030 // PXBDetId det(theDetUnit); 0031 // unsigned int module = bpixSidePhase0(theDetUnit); 0032 // if(!phase1 && (tt->pxbModule(theDetUnit) != module) ) 0033 // // phase1 code 0034 // unsigned int module1 = bpixSidePhase1(theDetUnit); 0035 // } 0036 // } else { 0037 // // Endcaps, use the panel to find the direction 0038 // if((tt->pxfPanel(theDetUnit))==1) side=-1; // panel 1 0039 // else side =1; // panel 2 0040 // if(TEST) { 0041 // // code -phase0 0042 // PXFDetId det(theDetUnit); 0043 // unsigned int module = fpixSidePhase0(theDetUnit); 0044 // // phase1 code 0045 // unsigned int module1 = fpixSidePhase1(theDetUnit); 0046 // } 0047 // } 0048 // theFrameConverter = FrameConversion(isBarrel,side, theIdDU); 0049 // } else { // phase0 0050 // initFrameConversion(); // old code for phase0 0051 // } 0052 // } 0053 0054 // works for phase 1, find det side from the local method 0055 // Frame conversion compatible with CMSSW_9_0_X Monte Carlo samples 0056 void PixelROC::initFrameConversionPhase1_CMSSW_9_0_X() { 0057 int side = 0; 0058 bool isBarrel = PixelModuleName::isBarrel(theDetUnit); 0059 if (isBarrel) { 0060 side = bpixSidePhase1(theDetUnit); // find the side for phase1 0061 } else { 0062 side = fpixSidePhase1(theDetUnit); 0063 } 0064 0065 theFrameConverter = FrameConversion(isBarrel, side, theIdDU); 0066 } 0067 0068 // works for phase 1, find det side from the local method 0069 void PixelROC::initFrameConversionPhase1() { 0070 int side = 0; 0071 int layer = 0; 0072 bool isBarrel = PixelModuleName::isBarrel(theDetUnit); 0073 if (isBarrel) { 0074 side = bpixSidePhase1(theDetUnit); // find the side for phase1 0075 layer = bpixLayerPhase1(theDetUnit); 0076 } else { 0077 side = fpixSidePhase1(theDetUnit); 0078 } 0079 0080 theFrameConverter = FrameConversion(isBarrel, side, layer, theIdDU); 0081 } 0082 0083 // Works only for phase0, uses the fixed pixel id 0084 void PixelROC::initFrameConversion() { 0085 if (PixelModuleName::isBarrel(theDetUnit)) { 0086 PixelBarrelName barrelName(theDetUnit); 0087 theFrameConverter = FrameConversion(barrelName, theIdDU); 0088 } else { 0089 PixelEndcapName endcapName(theDetUnit); 0090 theFrameConverter = FrameConversion(endcapName, theIdDU); 0091 } 0092 } 0093 0094 // These are methods to find the module side. 0095 // The are hardwired for phase0 and phase1 0096 // Will not work for phase2 or when the detid coding changes. 0097 int PixelROC::bpixSidePhase0(uint32_t rawId) const { 0098 int side = 1; 0099 /// two bits would be enough, but we could use the number "0" as a wildcard 0100 //const unsigned int layerStartBit_= 16; 0101 //const unsigned int ladderStartBit_= 8; 0102 const unsigned int moduleStartBit_ = 2; 0103 /// two bits would be enough, but we could use the number "0" as a wildcard 0104 //const unsigned int layerMask_= 0xF; 0105 //const unsigned int ladderMask_= 0xFF; 0106 const unsigned int moduleMask_ = 0x3F; 0107 0108 /// layer id 0109 //unsigned int layer = (rawId>>layerStartBit_) & layerMask_; 0110 /// ladder id 0111 //unsigned int ladder = (rawId>>ladderStartBit_) & ladderMask_; 0112 /// det id 0113 unsigned int module = (rawId >> moduleStartBit_) & moduleMask_; 0114 0115 if (module < 5) 0116 side = -1; // modules 1-4 are on -z 0117 return side; 0118 } 0119 int PixelROC::bpixSidePhase1(uint32_t rawId) const { 0120 int side = 1; 0121 0122 /// two bits would be enough, but we could use the number "0" as a wildcard 0123 //const unsigned int layerStartBit_= 20; 0124 //const unsigned int ladderStartBit_= 12; 0125 const unsigned int moduleStartBit_ = 2; 0126 /// two bits would be enough, but we could use the number "0" as a wildcard 0127 //const unsigned int layerMask_= 0xF; 0128 //const unsigned int ladderMask_= 0xFF; 0129 const unsigned int moduleMask_ = 0x3FF; 0130 0131 /// layer id 0132 //unsigned int layer = (rawId>>layerStartBit_) & layerMask_; 0133 /// ladder id 0134 //unsigned int ladder = (rawId>>ladderStartBit_) & ladderMask_; 0135 /// det id 0136 unsigned int module = (rawId >> moduleStartBit_) & moduleMask_; 0137 0138 if (module < 5) 0139 side = -1; // modules 1-4 are on -z 0140 return side; 0141 } 0142 int PixelROC::bpixLayerPhase1(uint32_t rawId) { 0143 /// two bits would be enough, but we could use the number "0" as a wildcard 0144 const unsigned int layerStartBit_ = 20; 0145 //const unsigned int ladderStartBit_= 12; 0146 //const unsigned int moduleStartBit_= 2; 0147 /// two bits would be enough, but we could use the number "0" as a wildcard 0148 const unsigned int layerMask_ = 0xF; 0149 //const unsigned int ladderMask_= 0xFF; 0150 //const unsigned int moduleMask_= 0x3FF; 0151 0152 /// layer id 0153 unsigned int layer = (rawId >> layerStartBit_) & layerMask_; 0154 /// ladder id 0155 //unsigned int ladder = (rawId>>ladderStartBit_) & ladderMask_; 0156 /// det id 0157 //unsigned int module = (rawId>>moduleStartBit_)& moduleMask_; 0158 0159 //if(module<5) side=-1; // modules 1-4 are on -z 0160 return layer; 0161 } 0162 0163 int PixelROC::fpixSidePhase0(uint32_t rawId) const { 0164 int side = 1; 0165 0166 /// two bits would be enough, but we could use the number "0" as a wildcard 0167 //const unsigned int sideStartBit_= 23; 0168 //const unsigned int diskStartBit_= 16; 0169 //const unsigned int bladeStartBit_= 10; 0170 const unsigned int panelStartBit_ = 8; 0171 //const unsigned int moduleStartBit_= 2; 0172 /// two bits would be enough, but we could use the number "0" as a wildcard 0173 0174 //const unsigned int sideMask_= 0x3; 0175 //const unsigned int diskMask_= 0xF; 0176 //const unsigned int bladeMask_= 0x3F; 0177 const unsigned int panelMask_ = 0x3; 0178 //const unsigned int moduleMask_= 0x3F; 0179 0180 /// positive or negative id 0181 //unsigned int sides = int((rawId>>sideStartBit_) & sideMask_); 0182 /// disk id 0183 //unsigned int disk = int((rawId>>diskStartBit_) & diskMask_); 0184 /// blade id 0185 //unsigned int blade = ((rawId>>bladeStartBit_) & bladeMask_); 0186 /// panel id 0187 unsigned int panel = ((rawId >> panelStartBit_) & panelMask_); 0188 /// det id 0189 //unsigned int module = ((rawId>>moduleStartBit_) & moduleMask_); 0190 0191 if (panel == 1) 0192 side = -1; // panel 1 faces -z (is this true for all disks?) 0193 return side; 0194 } 0195 int PixelROC::fpixSidePhase1(uint32_t rawId) const { 0196 int side = 1; 0197 0198 /// two bits would be enough, but we could use the number "0" as a wildcard 0199 //const unsigned int sideStartBit_= 23; 0200 //const unsigned int diskStartBit_= 18; 0201 //const unsigned int bladeStartBit_= 12; 0202 const unsigned int panelStartBit_ = 10; 0203 //const unsigned int moduleStartBit_= 2; 0204 /// two bits would be enough, but we could use the number "0" as a wildcard 0205 0206 //const unsigned int sideMask_= 0x3; 0207 //const unsigned int diskMask_= 0xF; 0208 //const unsigned int bladeMask_= 0x3F; 0209 const unsigned int panelMask_ = 0x3; 0210 //const unsigned int moduleMask_= 0xFF; 0211 0212 /// positive or negative id 0213 //unsigned int sides = int((rawId>>sideStartBit_) & sideMask_); 0214 /// disk id 0215 //unsigned int disk = int((rawId>>diskStartBit_) & diskMask_); 0216 0217 /// blade id 0218 //unsigned int blade = ((rawId>>bladeStartBit_) & bladeMask_); 0219 0220 /// panel id 1 or 2 0221 unsigned int panel = ((rawId >> panelStartBit_) & panelMask_); 0222 0223 /// det id 0224 //unsigned int module = ((rawId>>moduleStartBit_) & moduleMask_); 0225 0226 if (panel == 1) 0227 side = -1; // panel 1 faces -z (is this true for all disks?) 0228 return side; 0229 } 0230 0231 string PixelROC::print(int depth) const { 0232 ostringstream out; 0233 bool barrel = PixelModuleName::isBarrel(theDetUnit); 0234 DetId detId(theDetUnit); 0235 if (depth-- >= 0) { 0236 out << "======== PixelROC "; 0237 //out <<" unit: "; 0238 //if (barrel) out << PixelBarrelName(detId).name(); 0239 //else out << PixelEndcapName(detId).name(); 0240 if (barrel) 0241 out << " barrel "; 0242 else 0243 out << " endcap "; 0244 out << " (" << theDetUnit << ")" 0245 << " idInDU: " << theIdDU << " idInLk: " 0246 << theIdLk 0247 // <<" frame: "<<theRowOffset<<","<<theRowSlopeSign<<","<<theColOffset<<","<<theColSlopeSign 0248 // <<" frame: "<<*theFrameConverter 0249 << endl; 0250 } 0251 return out.str(); 0252 }
[ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
This page was automatically generated by the 2.2.1 LXR engine. The LXR team |
![]() ![]() |