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
57  int side = 0;
59  if(isBarrel) {
60  side = bpixSidePhase1(theDetUnit); // find the side for phase1
61  } else {
62  side = fpixSidePhase1(theDetUnit);
63  }
64 
65  theFrameConverter = FrameConversion(isBarrel,side, theIdDU);
66 
67 }
68 
69 // Works only for phase0, uses the fixed pixel id
71 
73  PixelBarrelName barrelName(theDetUnit);
75  } else {
76  PixelEndcapName endcapName(theDetUnit);
78  }
79 
80 }
81 
82 // These are methods to find the module side.
83 // The are hardwired for phase0 and phase1
84 // Will not work for phase2 or when the detid coding changes.
85 int PixelROC::bpixSidePhase0(uint32_t rawId) const {
86  int side = 1;
88  //const unsigned int layerStartBit_= 16;
89  //const unsigned int ladderStartBit_= 8;
90  const unsigned int moduleStartBit_= 2;
92  //const unsigned int layerMask_= 0xF;
93  //const unsigned int ladderMask_= 0xFF;
94  const unsigned int moduleMask_= 0x3F;
95 
97  //unsigned int layer = (rawId>>layerStartBit_) & layerMask_;
99  //unsigned int ladder = (rawId>>ladderStartBit_) & ladderMask_;
101  unsigned int module = (rawId>>moduleStartBit_)& moduleMask_;
102 
103  if(module<5) side=-1; // modules 1-4 are on -z
104  return side;
105 }
106 int PixelROC::bpixSidePhase1(uint32_t rawId) const {
107  int side = 1;
108 
110  //const unsigned int layerStartBit_= 20;
111  //const unsigned int ladderStartBit_= 12;
112  const unsigned int moduleStartBit_= 2;
114  //const unsigned int layerMask_= 0xF;
115  //const unsigned int ladderMask_= 0xFF;
116  const unsigned int moduleMask_= 0x3FF;
117 
119  //unsigned int layer = (rawId>>layerStartBit_) & layerMask_;
121  //unsigned int ladder = (rawId>>ladderStartBit_) & ladderMask_;
123  unsigned int module = (rawId>>moduleStartBit_)& moduleMask_;
124 
125  if(module<5) side=-1; // modules 1-4 are on -z
126  return side;
127 }
130  const unsigned int layerStartBit_= 20;
131  //const unsigned int ladderStartBit_= 12;
132  //const unsigned int moduleStartBit_= 2;
134  const unsigned int layerMask_= 0xF;
135  //const unsigned int ladderMask_= 0xFF;
136  //const unsigned int moduleMask_= 0x3FF;
137 
139  unsigned int layer = (rawId>>layerStartBit_) & layerMask_;
141  //unsigned int ladder = (rawId>>ladderStartBit_) & ladderMask_;
143  //unsigned int module = (rawId>>moduleStartBit_)& moduleMask_;
144 
145  //if(module<5) side=-1; // modules 1-4 are on -z
146  return layer;
147 }
148 
149 int PixelROC::fpixSidePhase0(uint32_t rawId) const {
150  int side = 1;
151 
153  //const unsigned int sideStartBit_= 23;
154  //const unsigned int diskStartBit_= 16;
155  //const unsigned int bladeStartBit_= 10;
156  const unsigned int panelStartBit_= 8;
157  //const unsigned int moduleStartBit_= 2;
159 
160  //const unsigned int sideMask_= 0x3;
161  //const unsigned int diskMask_= 0xF;
162  //const unsigned int bladeMask_= 0x3F;
163  const unsigned int panelMask_= 0x3;
164  //const unsigned int moduleMask_= 0x3F;
165 
167  //unsigned int sides = int((rawId>>sideStartBit_) & sideMask_);
169  //unsigned int disk = int((rawId>>diskStartBit_) & diskMask_);
171  //unsigned int blade = ((rawId>>bladeStartBit_) & bladeMask_);
173  unsigned int panel = ((rawId>>panelStartBit_) & panelMask_);
175  //unsigned int module = ((rawId>>moduleStartBit_) & moduleMask_);
176 
177  if(panel==1) side=-1; // panel 1 faces -z (is this true for all disks?)
178  return side;
179 }
180 int PixelROC::fpixSidePhase1(uint32_t rawId) const {
181  int side = 1;
182 
184  //const unsigned int sideStartBit_= 23;
185  //const unsigned int diskStartBit_= 18;
186  //const unsigned int bladeStartBit_= 12;
187  const unsigned int panelStartBit_= 10;
188  //const unsigned int moduleStartBit_= 2;
190 
191  //const unsigned int sideMask_= 0x3;
192  //const unsigned int diskMask_= 0xF;
193  //const unsigned int bladeMask_= 0x3F;
194  const unsigned int panelMask_= 0x3;
195  //const unsigned int moduleMask_= 0xFF;
196 
198  //unsigned int sides = int((rawId>>sideStartBit_) & sideMask_);
200  //unsigned int disk = int((rawId>>diskStartBit_) & diskMask_);
201 
203  //unsigned int blade = ((rawId>>bladeStartBit_) & bladeMask_);
204 
206  unsigned int panel = ((rawId>>panelStartBit_) & panelMask_);
207 
209  //unsigned int module = ((rawId>>moduleStartBit_) & moduleMask_);
210 
211  if(panel==1) side=-1; // panel 1 faces -z (is this true for all disks?)
212  return side;
213 }
214 
215 
216 string PixelROC::print(int depth) const {
217 
218  ostringstream out;
220  DetId detId(theDetUnit);
221  if (depth-- >=0 ) {
222  out <<"======== PixelROC ";
223  //out <<" unit: ";
224  //if (barrel) out << PixelBarrelName(detId).name();
225  //else out << PixelEndcapName(detId).name();
226  if (barrel) out << " barrel ";
227  else out << " endcap ";
228  out <<" ("<<theDetUnit<<")"
229  <<" idInDU: "<<theIdDU
230  <<" idInLk: "<<theIdLk
231 // <<" frame: "<<theRowOffset<<","<<theRowSlopeSign<<","<<theColOffset<<","<<theColSlopeSign
232 // <<" frame: "<<*theFrameConverter
233  <<endl;
234  }
235  return out.str();
236 }
237 
int fpixSidePhase1(uint32_t rawId) const
Definition: PixelROC.cc:180
std::string print(int depth=0) const
printout for debug
Definition: PixelROC.cc:216
uint32_t rawId() const
return the DetUnit to which this ROC belongs to.
Definition: PixelROC.h:37
FrameConversion theFrameConverter
Definition: PixelROC.h:85
unsigned int theIdLk
Definition: PixelROC.h:84
unsigned int theIdDU
Definition: PixelROC.h:84
virtual bool isBarrel() const
true for barrel modules
Definition: DetId.h:18
int fpixSidePhase0(uint32_t rawId) const
Definition: PixelROC.cc:149
static int bpixLayerPhase1(uint32_t rawId)
Definition: PixelROC.cc:128
int bpixSidePhase0(uint32_t rawId) const
Definition: PixelROC.cc:85
void initFrameConversionPhase1()
Definition: PixelROC.cc:56
Definition: vlib.h:208
int bpixSidePhase1(uint32_t rawId) const
Definition: PixelROC.cc:106