CMS 3D CMS Logo

PixelROC.cc
Go to the documentation of this file.
2 
6 
7 #include <sstream>
8 #include <algorithm>
9 using namespace std;
10 using namespace sipixelobjects;
11 
12 // Constructor with transformation frame initilization - NEVER CALLED
13 PixelROC::PixelROC(uint32_t du, int idDU, int idLk)
14  : theDetUnit(du), theIdDU(idDU), theIdLk(idLk) {
16 }
17 
18 // // for testing, uses topology fot det id, it works but I cannot pass topology here
19 // // not used
20 // void PixelROC::initFrameConversion(const TrackerTopology *tt, bool phase1) {
21 // const bool TEST = false;
22 // if(phase1) { // phase1
23 // bool isBarrel = PixelModuleName::isBarrel(theDetUnit);
24 // int side = 0;
25 // if(isBarrel) {
26 // // Barrel Z-index=1,8
27 // if((tt->pxbModule(theDetUnit))<5) side=-1;
28 // else side=1;
29 // if(TEST) {
30 // // phase0 code
31 // PXBDetId det(theDetUnit);
32 // unsigned int module = bpixSidePhase0(theDetUnit);
33 // if(!phase1 && (tt->pxbModule(theDetUnit) != module) )
34 // // phase1 code
35 // unsigned int module1 = bpixSidePhase1(theDetUnit);
36 // }
37 // } else {
38 // // Endcaps, use the panel to find the direction
39 // if((tt->pxfPanel(theDetUnit))==1) side=-1; // panel 1
40 // else side =1; // panel 2
41 // if(TEST) {
42 // // code -phase0
43 // PXFDetId det(theDetUnit);
44 // unsigned int module = fpixSidePhase0(theDetUnit);
45 // // phase1 code
46 // unsigned int module1 = fpixSidePhase1(theDetUnit);
47 // }
48 // }
49 // theFrameConverter = FrameConversion(isBarrel,side, theIdDU);
50 // } else { // phase0
51 // initFrameConversion(); // old code for phase0
52 // }
53 // }
54 
55 // works for phase 1, find det side from the local method
56 // Frame conversion compatible with CMSSW_9_0_X Monte Carlo samples
58  int side = 0;
60  if(isBarrel) {
61  side = bpixSidePhase1(theDetUnit); // find the side for phase1
62  } else {
63  side = fpixSidePhase1(theDetUnit);
64  }
65 
66  theFrameConverter = FrameConversion(isBarrel,side, theIdDU);
67 
68 }
69 
70 // works for phase 1, find det side from the local method
72  int side = 0;
73  int layer = 0;
75  if(isBarrel) {
76  side = bpixSidePhase1(theDetUnit); // find the side for phase1
77  layer = bpixLayerPhase1(theDetUnit);
78  } else {
79  side = fpixSidePhase1(theDetUnit);
80  }
81 
82  theFrameConverter = FrameConversion(isBarrel, side, layer, theIdDU);
83 
84 }
85 
86 // Works only for phase0, uses the fixed pixel id
88 
90  PixelBarrelName barrelName(theDetUnit);
92  } else {
93  PixelEndcapName endcapName(theDetUnit);
95  }
96 
97 }
98 
99 // These are methods to find the module side.
100 // The are hardwired for phase0 and phase1
101 // Will not work for phase2 or when the detid coding changes.
102 int PixelROC::bpixSidePhase0(uint32_t rawId) const {
103  int side = 1;
105  //const unsigned int layerStartBit_= 16;
106  //const unsigned int ladderStartBit_= 8;
107  const unsigned int moduleStartBit_= 2;
109  //const unsigned int layerMask_= 0xF;
110  //const unsigned int ladderMask_= 0xFF;
111  const unsigned int moduleMask_= 0x3F;
112 
114  //unsigned int layer = (rawId>>layerStartBit_) & layerMask_;
116  //unsigned int ladder = (rawId>>ladderStartBit_) & ladderMask_;
118  unsigned int module = (rawId>>moduleStartBit_)& moduleMask_;
119 
120  if(module<5) side=-1; // modules 1-4 are on -z
121  return side;
122 }
123 int PixelROC::bpixSidePhase1(uint32_t rawId) const {
124  int side = 1;
125 
127  //const unsigned int layerStartBit_= 20;
128  //const unsigned int ladderStartBit_= 12;
129  const unsigned int moduleStartBit_= 2;
131  //const unsigned int layerMask_= 0xF;
132  //const unsigned int ladderMask_= 0xFF;
133  const unsigned int moduleMask_= 0x3FF;
134 
136  //unsigned int layer = (rawId>>layerStartBit_) & layerMask_;
138  //unsigned int ladder = (rawId>>ladderStartBit_) & ladderMask_;
140  unsigned int module = (rawId>>moduleStartBit_)& moduleMask_;
141 
142  if(module<5) side=-1; // modules 1-4 are on -z
143  return side;
144 }
147  const unsigned int layerStartBit_= 20;
148  //const unsigned int ladderStartBit_= 12;
149  //const unsigned int moduleStartBit_= 2;
151  const unsigned int layerMask_= 0xF;
152  //const unsigned int ladderMask_= 0xFF;
153  //const unsigned int moduleMask_= 0x3FF;
154 
156  unsigned int layer = (rawId>>layerStartBit_) & layerMask_;
158  //unsigned int ladder = (rawId>>ladderStartBit_) & ladderMask_;
160  //unsigned int module = (rawId>>moduleStartBit_)& moduleMask_;
161 
162  //if(module<5) side=-1; // modules 1-4 are on -z
163  return layer;
164 }
165 
166 int PixelROC::fpixSidePhase0(uint32_t rawId) const {
167  int side = 1;
168 
170  //const unsigned int sideStartBit_= 23;
171  //const unsigned int diskStartBit_= 16;
172  //const unsigned int bladeStartBit_= 10;
173  const unsigned int panelStartBit_= 8;
174  //const unsigned int moduleStartBit_= 2;
176 
177  //const unsigned int sideMask_= 0x3;
178  //const unsigned int diskMask_= 0xF;
179  //const unsigned int bladeMask_= 0x3F;
180  const unsigned int panelMask_= 0x3;
181  //const unsigned int moduleMask_= 0x3F;
182 
184  //unsigned int sides = int((rawId>>sideStartBit_) & sideMask_);
186  //unsigned int disk = int((rawId>>diskStartBit_) & diskMask_);
188  //unsigned int blade = ((rawId>>bladeStartBit_) & bladeMask_);
190  unsigned int panel = ((rawId>>panelStartBit_) & panelMask_);
192  //unsigned int module = ((rawId>>moduleStartBit_) & moduleMask_);
193 
194  if(panel==1) side=-1; // panel 1 faces -z (is this true for all disks?)
195  return side;
196 }
197 int PixelROC::fpixSidePhase1(uint32_t rawId) const {
198  int side = 1;
199 
201  //const unsigned int sideStartBit_= 23;
202  //const unsigned int diskStartBit_= 18;
203  //const unsigned int bladeStartBit_= 12;
204  const unsigned int panelStartBit_= 10;
205  //const unsigned int moduleStartBit_= 2;
207 
208  //const unsigned int sideMask_= 0x3;
209  //const unsigned int diskMask_= 0xF;
210  //const unsigned int bladeMask_= 0x3F;
211  const unsigned int panelMask_= 0x3;
212  //const unsigned int moduleMask_= 0xFF;
213 
215  //unsigned int sides = int((rawId>>sideStartBit_) & sideMask_);
217  //unsigned int disk = int((rawId>>diskStartBit_) & diskMask_);
218 
220  //unsigned int blade = ((rawId>>bladeStartBit_) & bladeMask_);
221 
223  unsigned int panel = ((rawId>>panelStartBit_) & panelMask_);
224 
226  //unsigned int module = ((rawId>>moduleStartBit_) & moduleMask_);
227 
228  if(panel==1) side=-1; // panel 1 faces -z (is this true for all disks?)
229  return side;
230 }
231 
232 
233 string PixelROC::print(int depth) const {
234 
235  ostringstream out;
237  DetId detId(theDetUnit);
238  if (depth-- >=0 ) {
239  out <<"======== PixelROC ";
240  //out <<" unit: ";
241  //if (barrel) out << PixelBarrelName(detId).name();
242  //else out << PixelEndcapName(detId).name();
243  if (barrel) out << " barrel ";
244  else out << " endcap ";
245  out <<" ("<<theDetUnit<<")"
246  <<" idInDU: "<<theIdDU
247  <<" idInLk: "<<theIdLk
248 // <<" frame: "<<theRowOffset<<","<<theRowSlopeSign<<","<<theColOffset<<","<<theColSlopeSign
249 // <<" frame: "<<*theFrameConverter
250  <<endl;
251  }
252  return out.str();
253 }
254 
int fpixSidePhase1(uint32_t rawId) const
Definition: PixelROC.cc:197
bool isBarrel(GeomDetEnumerators::SubDetector m)
void initFrameConversionPhase1_CMSSW_9_0_X()
Definition: PixelROC.cc:57
std::string print(int depth=0) const
printout for debug
Definition: PixelROC.cc:233
uint32_t rawId() const
return the DetUnit to which this ROC belongs to.
Definition: PixelROC.h:37
FrameConversion theFrameConverter
Definition: PixelROC.h:87
unsigned int theIdLk
Definition: PixelROC.h:86
unsigned int theIdDU
Definition: PixelROC.h:86
virtual bool isBarrel() const
true for barrel modules
Definition: DetId.h:18
int fpixSidePhase0(uint32_t rawId) const
Definition: PixelROC.cc:166
static int bpixLayerPhase1(uint32_t rawId)
Definition: PixelROC.cc:145
int bpixSidePhase0(uint32_t rawId) const
Definition: PixelROC.cc:102
void initFrameConversionPhase1()
Definition: PixelROC.cc:71
Definition: vlib.h:208
int bpixSidePhase1(uint32_t rawId) const
Definition: PixelROC.cc:123