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) : theDetUnit(du), theIdDU(idDU), theIdLk(idLk) {
15 }
16 
17 // // for testing, uses topology fot det id, it works but I cannot pass topology here
18 // // not used
19 // void PixelROC::initFrameConversion(const TrackerTopology *tt, bool phase1) {
20 // const bool TEST = false;
21 // if(phase1) { // phase1
22 // bool isBarrel = PixelModuleName::isBarrel(theDetUnit);
23 // int side = 0;
24 // if(isBarrel) {
25 // // Barrel Z-index=1,8
26 // if((tt->pxbModule(theDetUnit))<5) side=-1;
27 // else side=1;
28 // if(TEST) {
29 // // phase0 code
30 // PXBDetId det(theDetUnit);
31 // unsigned int module = bpixSidePhase0(theDetUnit);
32 // if(!phase1 && (tt->pxbModule(theDetUnit) != module) )
33 // // phase1 code
34 // unsigned int module1 = bpixSidePhase1(theDetUnit);
35 // }
36 // } else {
37 // // Endcaps, use the panel to find the direction
38 // if((tt->pxfPanel(theDetUnit))==1) side=-1; // panel 1
39 // else side =1; // panel 2
40 // if(TEST) {
41 // // code -phase0
42 // PXFDetId det(theDetUnit);
43 // unsigned int module = fpixSidePhase0(theDetUnit);
44 // // phase1 code
45 // unsigned int module1 = fpixSidePhase1(theDetUnit);
46 // }
47 // }
48 // theFrameConverter = FrameConversion(isBarrel,side, theIdDU);
49 // } else { // phase0
50 // initFrameConversion(); // old code for phase0
51 // }
52 // }
53 
54 // works for phase 1, find det side from the local method
55 // Frame conversion compatible with CMSSW_9_0_X Monte Carlo samples
57  int side = 0;
59  if (isBarrel) {
60  side = bpixSidePhase1(theDetUnit); // find the side for phase1
61  } else {
63  }
64 
66 }
67 
68 // works for phase 1, find det side from the local method
70  int side = 0;
71  int layer = 0;
73  if (isBarrel) {
74  side = bpixSidePhase1(theDetUnit); // find the side for phase1
75  layer = bpixLayerPhase1(theDetUnit);
76  } else {
78  }
79 
81 }
82 
83 // Works only for phase0, uses the fixed pixel id
86  PixelBarrelName barrelName(theDetUnit);
88  } else {
89  PixelEndcapName endcapName(theDetUnit);
91  }
92 }
93 
94 // These are methods to find the module side.
95 // The are hardwired for phase0 and phase1
96 // Will not work for phase2 or when the detid coding changes.
97 int PixelROC::bpixSidePhase0(uint32_t rawId) const {
98  int side = 1;
100  //const unsigned int layerStartBit_= 16;
101  //const unsigned int ladderStartBit_= 8;
102  const unsigned int moduleStartBit_ = 2;
104  //const unsigned int layerMask_= 0xF;
105  //const unsigned int ladderMask_= 0xFF;
106  const unsigned int moduleMask_ = 0x3F;
107 
109  //unsigned int layer = (rawId>>layerStartBit_) & layerMask_;
111  //unsigned int ladder = (rawId>>ladderStartBit_) & ladderMask_;
113  unsigned int module = (rawId >> moduleStartBit_) & moduleMask_;
114 
115  if (module < 5)
116  side = -1; // modules 1-4 are on -z
117  return side;
118 }
119 int PixelROC::bpixSidePhase1(uint32_t rawId) const {
120  int side = 1;
121 
123  //const unsigned int layerStartBit_= 20;
124  //const unsigned int ladderStartBit_= 12;
125  const unsigned int moduleStartBit_ = 2;
127  //const unsigned int layerMask_= 0xF;
128  //const unsigned int ladderMask_= 0xFF;
129  const unsigned int moduleMask_ = 0x3FF;
130 
132  //unsigned int layer = (rawId>>layerStartBit_) & layerMask_;
134  //unsigned int ladder = (rawId>>ladderStartBit_) & ladderMask_;
136  unsigned int module = (rawId >> moduleStartBit_) & moduleMask_;
137 
138  if (module < 5)
139  side = -1; // modules 1-4 are on -z
140  return side;
141 }
144  const unsigned int layerStartBit_ = 20;
145  //const unsigned int ladderStartBit_= 12;
146  //const unsigned int moduleStartBit_= 2;
148  const unsigned int layerMask_ = 0xF;
149  //const unsigned int ladderMask_= 0xFF;
150  //const unsigned int moduleMask_= 0x3FF;
151 
153  unsigned int layer = (rawId >> layerStartBit_) & layerMask_;
155  //unsigned int ladder = (rawId>>ladderStartBit_) & ladderMask_;
157  //unsigned int module = (rawId>>moduleStartBit_)& moduleMask_;
158 
159  //if(module<5) side=-1; // modules 1-4 are on -z
160  return layer;
161 }
162 
163 int PixelROC::fpixSidePhase0(uint32_t rawId) const {
164  int side = 1;
165 
167  //const unsigned int sideStartBit_= 23;
168  //const unsigned int diskStartBit_= 16;
169  //const unsigned int bladeStartBit_= 10;
170  const unsigned int panelStartBit_ = 8;
171  //const unsigned int moduleStartBit_= 2;
173 
174  //const unsigned int sideMask_= 0x3;
175  //const unsigned int diskMask_= 0xF;
176  //const unsigned int bladeMask_= 0x3F;
177  const unsigned int panelMask_ = 0x3;
178  //const unsigned int moduleMask_= 0x3F;
179 
181  //unsigned int sides = int((rawId>>sideStartBit_) & sideMask_);
183  //unsigned int disk = int((rawId>>diskStartBit_) & diskMask_);
185  //unsigned int blade = ((rawId>>bladeStartBit_) & bladeMask_);
187  unsigned int panel = ((rawId >> panelStartBit_) & panelMask_);
189  //unsigned int module = ((rawId>>moduleStartBit_) & moduleMask_);
190 
191  if (panel == 1)
192  side = -1; // panel 1 faces -z (is this true for all disks?)
193  return side;
194 }
195 int PixelROC::fpixSidePhase1(uint32_t rawId) const {
196  int side = 1;
197 
199  //const unsigned int sideStartBit_= 23;
200  //const unsigned int diskStartBit_= 18;
201  //const unsigned int bladeStartBit_= 12;
202  const unsigned int panelStartBit_ = 10;
203  //const unsigned int moduleStartBit_= 2;
205 
206  //const unsigned int sideMask_= 0x3;
207  //const unsigned int diskMask_= 0xF;
208  //const unsigned int bladeMask_= 0x3F;
209  const unsigned int panelMask_ = 0x3;
210  //const unsigned int moduleMask_= 0xFF;
211 
213  //unsigned int sides = int((rawId>>sideStartBit_) & sideMask_);
215  //unsigned int disk = int((rawId>>diskStartBit_) & diskMask_);
216 
218  //unsigned int blade = ((rawId>>bladeStartBit_) & bladeMask_);
219 
221  unsigned int panel = ((rawId >> panelStartBit_) & panelMask_);
222 
224  //unsigned int module = ((rawId>>moduleStartBit_) & moduleMask_);
225 
226  if (panel == 1)
227  side = -1; // panel 1 faces -z (is this true for all disks?)
228  return side;
229 }
230 
231 string PixelROC::print(int depth) const {
232  ostringstream out;
235  if (depth-- >= 0) {
236  out << "======== PixelROC ";
237  //out <<" unit: ";
238  //if (barrel) out << PixelBarrelName(detId).name();
239  //else out << PixelEndcapName(detId).name();
240  if (barrel)
241  out << " barrel ";
242  else
243  out << " endcap ";
244  out << " (" << theDetUnit << ")"
245  << " idInDU: " << theIdDU << " idInLk: "
246  << theIdLk
247  // <<" frame: "<<theRowOffset<<","<<theRowSlopeSign<<","<<theColOffset<<","<<theColSlopeSign
248  // <<" frame: "<<*theFrameConverter
249  << endl;
250  }
251  return out.str();
252 }
int bpixSidePhase0(uint32_t rawId) const
Definition: PixelROC.cc:97
int bpixSidePhase1(uint32_t rawId) const
Definition: PixelROC.cc:119
void initFrameConversionPhase1_CMSSW_9_0_X()
Definition: PixelROC.cc:56
int fpixSidePhase1(uint32_t rawId) const
Definition: PixelROC.cc:195
FrameConversion theFrameConverter
Definition: PixelROC.h:83
unsigned int theIdLk
Definition: PixelROC.h:82
unsigned int theIdDU
Definition: PixelROC.h:82
std::string print(int depth=0) const
printout for debug
Definition: PixelROC.cc:231
Definition: DetId.h:17
virtual bool isBarrel() const
true for barrel modules
static int bpixLayerPhase1(uint32_t rawId)
Definition: PixelROC.cc:142
int fpixSidePhase0(uint32_t rawId) const
Definition: PixelROC.cc:163
void initFrameConversionPhase1()
Definition: PixelROC.cc:69
uint32_t rawId() const
return the DetUnit to which this ROC belongs to.
Definition: PixelROC.h:34