CMS 3D CMS Logo

SiPixelCoordinates.h
Go to the documentation of this file.
1 #ifndef SiPixelCoordinates_h
2 #define SiPixelCoordinates_h
3 // -*- C++ -*-
4 //
5 // Class: SiPixelCoordinates
6 //
7 // This class provides floating point numbers for
8 // digis, clusters and hits that can be used to
9 // easily plot various geometry related histograms
10 //
11 // Online and Offline conventions are kept for the variables
12 // An additional ]0, +1[ or ]-0.5, +0.5[ is added depending on
13 // the location of digi/cluster/hit on the module, so
14 // the variables provided are roughly monotonic vs. global
15 // coordinates (except that overlaps are removed), eg:
16 // global z: module, disk, disk_ring (large division)
17 // global r-phi: ladder, blade, blade_panel
18 // global r: ring, disk_ring (small division)
19 //
20 // Original Author: Janos Karancsi
21 
30 
31 #include <cstdint>
32 #include <unordered_map>
33 #include <utility>
34 
36 public:
38  SiPixelCoordinates(int);
39  virtual ~SiPixelCoordinates();
40 
41  void init(const TrackerTopology*, const TrackerGeometry*, const SiPixelFedCablingMap*);
42 
43  // Integers
44  int quadrant(const DetId&);
45  int side(const DetId&);
46  int module(const DetId&);
47  // barrel specific
48  int layer(const DetId&);
49  int sector(const DetId&);
50  int ladder(const DetId&);
51  int signed_ladder(const DetId&);
52  int signed_module(const DetId&);
53  int half(const DetId&);
54  int outer(const DetId&);
55  int flipped(const DetId&);
56  // endcap specific
57  int disk(const DetId&);
58  int signed_disk(const DetId&);
59  int panel(const DetId&);
60  int ring(const DetId&);
61  int blade(const DetId&);
62  int signed_blade(const DetId&);
63 
64  unsigned int fedid(const DetId&);
65 
66  int channel(const DetId&, const std::pair<int, int>&);
67  int channel(const DetId&, const PixelDigi*);
68  int channel(const DetId&, const SiPixelCluster*);
69  int channel(const SiPixelRecHit*);
70  int channel(const TrackingRecHit*);
71 
72  int roc(const DetId&, const std::pair<int, int>&);
73  int roc(const DetId&, const PixelDigi*);
74  int roc(const DetId&, const SiPixelCluster*);
75  int roc(const SiPixelRecHit*);
76  int roc(const TrackingRecHit*);
77 
78  // Floats (coordinates)
79  float module_coord(const DetId&, const std::pair<int, int>&);
80  float module_coord(const DetId&, const PixelDigi*);
81  float module_coord(const DetId&, const SiPixelCluster*);
82  float module_coord(const SiPixelRecHit*);
83  float module_coord(const TrackingRecHit*);
84 
85  float signed_module_coord(const DetId&, const std::pair<int, int>&);
86  float signed_module_coord(const DetId&, const PixelDigi*);
87  float signed_module_coord(const DetId&, const SiPixelCluster*);
88  float signed_module_coord(const SiPixelRecHit*);
89  float signed_module_coord(const TrackingRecHit*);
90 
91  float ladder_coord(const DetId&, const std::pair<int, int>&);
92  float ladder_coord(const DetId&, const PixelDigi*);
93  float ladder_coord(const DetId&, const SiPixelCluster*);
94  float ladder_coord(const SiPixelRecHit*);
95  float ladder_coord(const TrackingRecHit*);
96 
97  float signed_ladder_coord(const DetId&, const std::pair<int, int>&);
98  float signed_ladder_coord(const DetId&, const PixelDigi*);
99  float signed_ladder_coord(const DetId&, const SiPixelCluster*);
100  float signed_ladder_coord(const SiPixelRecHit*);
101  float signed_ladder_coord(const TrackingRecHit*);
102 
103  float ring_coord(const DetId&, const std::pair<int, int>&);
104  float ring_coord(const DetId&, const PixelDigi*);
105  float ring_coord(const DetId&, const SiPixelCluster*);
106  float ring_coord(const SiPixelRecHit*);
107  float ring_coord(const TrackingRecHit*);
108 
109  float disk_coord(const DetId&, const std::pair<int, int>&);
110  float disk_coord(const DetId&, const PixelDigi*);
111  float disk_coord(const DetId&, const SiPixelCluster*);
112  float disk_coord(const SiPixelRecHit*);
113  float disk_coord(const TrackingRecHit*);
114 
115  float signed_disk_coord(const DetId&, const std::pair<int, int>&);
116  float signed_disk_coord(const DetId&, const PixelDigi*);
117  float signed_disk_coord(const DetId&, const SiPixelCluster*);
118  float signed_disk_coord(const SiPixelRecHit*);
119  float signed_disk_coord(const TrackingRecHit*);
120 
121  float disk_ring_coord(const DetId&, const std::pair<int, int>&);
122  float disk_ring_coord(const DetId&, const PixelDigi*);
123  float disk_ring_coord(const DetId&, const SiPixelCluster*);
124  float disk_ring_coord(const SiPixelRecHit*);
125  float disk_ring_coord(const TrackingRecHit*);
126 
127  float signed_disk_ring_coord(const DetId&, const std::pair<int, int>&);
128  float signed_disk_ring_coord(const DetId&, const PixelDigi*);
129  float signed_disk_ring_coord(const DetId&, const SiPixelCluster*);
132 
133  float blade_coord(const DetId&, const std::pair<int, int>&);
134  float blade_coord(const DetId&, const PixelDigi*);
135  float blade_coord(const DetId&, const SiPixelCluster*);
136  float blade_coord(const SiPixelRecHit*);
137  float blade_coord(const TrackingRecHit*);
138 
139  float signed_blade_coord(const DetId&, const std::pair<int, int>&);
140  float signed_blade_coord(const DetId&, const PixelDigi*);
141  float signed_blade_coord(const DetId&, const SiPixelCluster*);
142  float signed_blade_coord(const SiPixelRecHit*);
143  float signed_blade_coord(const TrackingRecHit*);
144 
145  float blade_panel_coord(const DetId&, const std::pair<int, int>&);
146  float blade_panel_coord(const DetId&, const PixelDigi*);
147  float blade_panel_coord(const DetId&, const SiPixelCluster*);
148  float blade_panel_coord(const SiPixelRecHit*);
149  float blade_panel_coord(const TrackingRecHit*);
150 
151  float signed_blade_panel_coord(const DetId&, const std::pair<int, int>&);
152  float signed_blade_panel_coord(const DetId&, const PixelDigi*);
153  float signed_blade_panel_coord(const DetId&, const SiPixelCluster*);
156 
157  float signed_shifted_blade_panel_coord(const DetId&, const std::pair<int, int>&);
158  float signed_shifted_blade_panel_coord(const DetId&, const PixelDigi*);
162 
163 private:
164  int phase_;
165 
169 
170  // Internal containers for optimal speed
171  // - only calculate things once per DetId
172  std::unordered_map<uint32_t, int> quadrant_;
173  std::unordered_map<uint32_t, int> side_;
174  std::unordered_map<uint32_t, int> module_;
175  std::unordered_map<uint32_t, int> layer_;
176  std::unordered_map<uint32_t, int> sector_;
177  std::unordered_map<uint32_t, int> ladder_;
178  std::unordered_map<uint32_t, int> signed_ladder_;
179  std::unordered_map<uint32_t, int> signed_module_;
180  std::unordered_map<uint32_t, int> half_;
181  std::unordered_map<uint32_t, int> outer_;
182  std::unordered_map<uint32_t, int> flipped_;
183  std::unordered_map<uint32_t, int> disk_;
184  std::unordered_map<uint32_t, int> signed_disk_;
185  std::unordered_map<uint32_t, int> panel_;
186  std::unordered_map<uint32_t, int> ring_;
187  std::unordered_map<uint32_t, int> blade_;
188  std::unordered_map<uint32_t, int> signed_blade_;
189 
190  std::unordered_map<uint32_t, unsigned int> fedid_;
191  std::unordered_map<uint64_t, unsigned int> channel_;
192  std::unordered_map<uint64_t, unsigned int> roc_;
193 
194  // Internal methods used for pixel coordinates
195  bool isPixel_(const DetId&);
196  bool isBPix_(const DetId&);
197  bool isFPix_(const DetId&);
198  std::pair<int, int> pixel_(const PixelDigi*);
199  std::pair<int, int> pixel_(const SiPixelCluster*);
200  std::pair<int, int> pixel_(const SiPixelRecHit*);
201  float xcoord_on_module_(const DetId&, const std::pair<int, int>&);
202  float ycoord_on_module_(const DetId&, const std::pair<int, int>&);
203 };
204 
205 #endif
SiPixelCoordinates::signed_disk_
std::unordered_map< uint32_t, int > signed_disk_
Definition: SiPixelCoordinates.h:184
SiPixelCoordinates::side
int side(const DetId &)
Definition: SiPixelCoordinates.cc:70
SiPixelCoordinates::blade_
std::unordered_map< uint32_t, int > blade_
Definition: SiPixelCoordinates.h:187
TrackerGeometry.h
SiPixelCoordinates::signed_blade_coord
float signed_blade_coord(const DetId &, const std::pair< int, int > &)
Definition: SiPixelCoordinates.cc:900
SiPixelCoordinates::tTopo_
const TrackerTopology * tTopo_
Definition: SiPixelCoordinates.h:166
SiPixelCoordinates::layer
int layer(const DetId &)
Definition: SiPixelCoordinates.cc:94
SiPixelCoordinates::signed_ladder
int signed_ladder(const DetId &)
Definition: SiPixelCoordinates.cc:122
SiPixelCoordinates::signed_module_coord
float signed_module_coord(const DetId &, const std::pair< int, int > &)
Definition: SiPixelCoordinates.cc:559
SiPixelCoordinates::blade_coord
float blade_coord(const DetId &, const std::pair< int, int > &)
Definition: SiPixelCoordinates.cc:855
SiPixelCoordinates::isFPix_
bool isFPix_(const DetId &)
Definition: SiPixelCoordinates.cc:302
SiPixelCoordinates::module_coord
float module_coord(const DetId &, const std::pair< int, int > &)
Definition: SiPixelCoordinates.cc:531
SiPixelCoordinates::signed_shifted_blade_panel_coord
float signed_shifted_blade_panel_coord(const DetId &, const std::pair< int, int > &)
Definition: SiPixelCoordinates.cc:1012
TrackerTopology
Definition: TrackerTopology.h:16
SiPixelCoordinates::signed_blade
int signed_blade(const DetId &)
Definition: SiPixelCoordinates.cc:257
SiPixelCoordinates::blade_panel_coord
float blade_panel_coord(const DetId &, const std::pair< int, int > &)
Definition: SiPixelCoordinates.cc:943
SiPixelCluster.h
SiPixelCoordinates::signed_module_
std::unordered_map< uint32_t, int > signed_module_
Definition: SiPixelCoordinates.h:179
SiPixelCoordinates::fedid_
std::unordered_map< uint32_t, unsigned int > fedid_
Definition: SiPixelCoordinates.h:190
SiPixelCoordinates::signed_blade_panel_coord
float signed_blade_panel_coord(const DetId &, const std::pair< int, int > &)
Definition: SiPixelCoordinates.cc:978
PixelDigi
Definition: PixelDigi.h:14
SiPixelCoordinates::isBPix_
bool isBPix_(const DetId &)
Definition: SiPixelCoordinates.cc:295
SiPixelFedCablingMap.h
SiPixelCoordinates::pixel_
std::pair< int, int > pixel_(const PixelDigi *)
Definition: SiPixelCoordinates.cc:310
SiPixelCoordinates::half
int half(const DetId &)
Definition: SiPixelCoordinates.cc:147
SiPixelCoordinates::channel_
std::unordered_map< uint64_t, unsigned int > channel_
Definition: SiPixelCoordinates.h:191
PixelDigi.h
SiPixelCluster
Pixel cluster – collection of neighboring pixels above threshold.
Definition: SiPixelCluster.h:27
SiPixelCoordinates::flipped_
std::unordered_map< uint32_t, int > flipped_
Definition: SiPixelCoordinates.h:182
SiPixelCoordinates::sector
int sector(const DetId &)
Definition: SiPixelCoordinates.cc:103
SiPixelCoordinates::disk
int disk(const DetId &)
Definition: SiPixelCoordinates.cc:196
SiPixelRecHit
Our base class.
Definition: SiPixelRecHit.h:23
SiPixelCoordinates::sector_
std::unordered_map< uint32_t, int > sector_
Definition: SiPixelCoordinates.h:176
SiPixelCoordinates::ring_
std::unordered_map< uint32_t, int > ring_
Definition: SiPixelCoordinates.h:186
SiPixelCoordinates::signed_blade_
std::unordered_map< uint32_t, int > signed_blade_
Definition: SiPixelCoordinates.h:188
SiPixelCoordinates::isPixel_
bool isPixel_(const DetId &)
Definition: SiPixelCoordinates.cc:286
DetId
Definition: DetId.h:17
TrackerTopology.h
TrackingRecHit.h
SiPixelCoordinates::cablingMap_
const SiPixelFedCablingMap * cablingMap_
Definition: SiPixelCoordinates.h:168
SiPixelCoordinates::init
void init(const TrackerTopology *, const TrackerGeometry *, const SiPixelFedCablingMap *)
Definition: SiPixelCoordinates.cc:30
SiPixelCoordinates::phase_
int phase_
Definition: SiPixelCoordinates.h:164
SiPixelCoordinates::layer_
std::unordered_map< uint32_t, int > layer_
Definition: SiPixelCoordinates.h:175
SiPixelCoordinates::ladder_
std::unordered_map< uint32_t, int > ladder_
Definition: SiPixelCoordinates.h:177
SiPixelCoordinates::channel
int channel(const DetId &, const std::pair< int, int > &)
Definition: SiPixelCoordinates.cc:371
SiPixelCoordinates::signed_disk
int signed_disk(const DetId &)
Definition: SiPixelCoordinates.cc:206
SiPixelCoordinates::flipped
int flipped(const DetId &)
Definition: SiPixelCoordinates.cc:184
SiPixelCoordinates::side_
std::unordered_map< uint32_t, int > side_
Definition: SiPixelCoordinates.h:173
SiPixelRecHit.h
SiPixelCoordinates::fedid
unsigned int fedid(const DetId &)
Definition: SiPixelCoordinates.cc:269
SiPixelCoordinates::ring
int ring(const DetId &)
Definition: SiPixelCoordinates.cc:232
SiPixelCoordinates::outer_
std::unordered_map< uint32_t, int > outer_
Definition: SiPixelCoordinates.h:181
SiPixelCoordinates::~SiPixelCoordinates
virtual ~SiPixelCoordinates()
Definition: SiPixelCoordinates.cc:26
SiPixelCoordinates::roc_
std::unordered_map< uint64_t, unsigned int > roc_
Definition: SiPixelCoordinates.h:192
SiPixelCoordinates::module
int module(const DetId &)
Definition: SiPixelCoordinates.cc:82
SiPixelCoordinates::SiPixelCoordinates
SiPixelCoordinates()
Definition: SiPixelCoordinates.cc:22
SiPixelCoordinates::module_
std::unordered_map< uint32_t, int > module_
Definition: SiPixelCoordinates.h:174
SiPixelCoordinates::signed_disk_coord
float signed_disk_coord(const DetId &, const std::pair< int, int > &)
Definition: SiPixelCoordinates.cc:744
SiPixelFedCablingMap
Definition: SiPixelFedCablingMap.h:19
TrackingRecHit
Definition: TrackingRecHit.h:21
SiPixelCoordinates::disk_
std::unordered_map< uint32_t, int > disk_
Definition: SiPixelCoordinates.h:183
SiPixelCoordinates::ycoord_on_module_
float ycoord_on_module_(const DetId &, const std::pair< int, int > &)
Definition: SiPixelCoordinates.cc:346
SiPixelCoordinates::panel_
std::unordered_map< uint32_t, int > panel_
Definition: SiPixelCoordinates.h:185
SiPixelCoordinates::signed_disk_ring_coord
float signed_disk_ring_coord(const DetId &, const std::pair< int, int > &)
Definition: SiPixelCoordinates.cc:810
DetId.h
SiPixelCoordinates::signed_ladder_coord
float signed_ladder_coord(const DetId &, const std::pair< int, int > &)
Definition: SiPixelCoordinates.cc:617
SiPixelCoordinates::roc
int roc(const DetId &, const std::pair< int, int > &)
Definition: SiPixelCoordinates.cc:442
SiPixelCoordinates::disk_ring_coord
float disk_ring_coord(const DetId &, const std::pair< int, int > &)
Definition: SiPixelCoordinates.cc:777
SiPixelCoordinates::tGeom_
const TrackerGeometry * tGeom_
Definition: SiPixelCoordinates.h:167
SiPixelCoordinates::panel
int panel(const DetId &)
Definition: SiPixelCoordinates.cc:218
SiPixelCoordinates::signed_ladder_
std::unordered_map< uint32_t, int > signed_ladder_
Definition: SiPixelCoordinates.h:178
SiPixelCoordinates::half_
std::unordered_map< uint32_t, int > half_
Definition: SiPixelCoordinates.h:180
SiPixelCoordinates::outer
int outer(const DetId &)
Definition: SiPixelCoordinates.cc:160
SiPixelCoordinates::signed_module
int signed_module(const DetId &)
Definition: SiPixelCoordinates.cc:135
SiPixelCoordinates::ladder_coord
float ladder_coord(const DetId &, const std::pair< int, int > &)
Definition: SiPixelCoordinates.cc:587
SiPixelCoordinates
Definition: SiPixelCoordinates.h:35
SiPixelCoordinates::xcoord_on_module_
float xcoord_on_module_(const DetId &, const std::pair< int, int > &)
Definition: SiPixelCoordinates.cc:332
SiPixelCoordinates::ring_coord
float ring_coord(const DetId &, const std::pair< int, int > &)
Definition: SiPixelCoordinates.cc:654
SiPixelCoordinates::blade
int blade(const DetId &)
Definition: SiPixelCoordinates.cc:247
SiPixelCoordinates::ladder
int ladder(const DetId &)
Definition: SiPixelCoordinates.cc:112
SiPixelCoordinates::quadrant_
std::unordered_map< uint32_t, int > quadrant_
Definition: SiPixelCoordinates.h:172
SiPixelCoordinates::disk_coord
float disk_coord(const DetId &, const std::pair< int, int > &)
Definition: SiPixelCoordinates.cc:713
TrackerGeometry
Definition: TrackerGeometry.h:14
SiPixelCoordinates::quadrant
int quadrant(const DetId &)
Definition: SiPixelCoordinates.cc:56